How to cast a CDT into an new local variable, updating a field ?

Certified Senior Developer

Hi,

I'm trying to save into a local variable some data retrieved from an ER. But I would need to update some fields before to store it into my new local var.

Is there any way to do it ?

With the code below I can either cast the data, either create a new CDT local var with the new field value, but I did not succeed to do both. 

(as my CDT could contain more than 50 fields I do not want to override all theses 50 fields in the code below).

a!localVariables(
  local!vehicle: rule!TST_GetVehiclesWithFilters(
    id: 1
  ).data,
  
  local!vehicleCast: cast('type!{urn:com:appian:types:tst}TST_Vehicles', local!vehicle),
  local!vehicleUpdate: 'type!{urn:com:appian:types:tst}TST_Vehicles'(
    make: "New Make"
  ),

  {
    local!vehicleCast,
    local!vehicleUpdate
  }
)

Example : my initial data retreived by the ER is :

TST_Vehicles :

    • id : 1
      • make : "make1"
        • model : "model1"
          • ...
          • ...
          • ...
          • is_active : true

          and I would like my transformed data like this :

          TST_Vehicles

            • id : 1
              • make : "New make"
                • model : "model1"
                  • ...
                  • ...
                  • ...
                  • is_active : true

                    Discussion posts and replies are publicly visible

                  Parents Reply
                  • 0
                    Certified Senior Developer
                    in reply to Stefan Helzle

                    It contains a only one item DataSubset :

                    List of DataSubset - 1 item

                      • DataSubset
                          • startIndex 1(Number (Integer))
                            • batchSize 10(Number (Integer))
                              • sort List of SortInfo - 1 item
                                  • SortInfo
                                      • field"deleted"(Text)
                                        • ascendingtrue(Boolean)
                                      • totalCount 1(Number (Integer))
                                        • data List of Dictionary - 1 item
                                            • Dictionary
                                                • deleted false(Boolean)
                                                  • value 20(Number (Decimal))
                                                    • year 2022(Number (Integer))
                                                      • dateacquired null(Date)
                                                        • isavailable true(Boolean)
                                                          • vin ""(Text)
                                                            • model "model1"(Text)
                                                              • make "make1"(Text)
                                                                • id 1(Number (Integer))
                                                              • identifiers List of Number (Integer) - 1 item
                                                                  • 1(Number (Integer))
                                                            Children