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 :
and I would like my transformed data like this :
TST_Vehicles
Discussion posts and replies are publicly visible
This plugin should help
community.appian.com/.../cdt-manipulation
Thank you Stefan but I've already tested it without success.
Am I forgetting something ? (the value of the "make" field does not change)
a!localVariables( local!vehicle: rule!TST_GetVehiclesWithFilters( id: 1 ), local!vehicleUpdateCDT: updatedictionary( dictionary: local!vehicle, fieldsAndValues: ( { make: "test2" } ) ), { local!vehicleUpdateCDT } )
Lines 7-10 should look like
fieldsAndValues: { make: "test2" }
There are to many brackets.
I've already used this plugin with this ({ }), and it has worked well.
But in my below ER example, it still does not work (according your suggestion).
Would you see another error ?
a!localVariables( local!item: rule!SBA_QR_GetConfigurationItemByIdent(1), updatedictionary( local!item, { name: "Hans" } ) )
My small test. Works a expected for dictionaries, maps and CDTs. How does your CDT look like? There are some quirks with certain data type.
My test CDT contains standard data types :
a!localVariables( local!item: {name: "NOT HANS"}, updatedictionary( local!item, { name: "HANS" } ) )
Does this work for you?
yes, this works fine.
In this code of yours
What is the actual content of local!vehicle? Datasubset / single item / list of items?
It contains a only one item DataSubset :
List of DataSubset - 1 item
OK. Then you need to drill down like local!vehicle.data[1].
Very good Idea, I did not think about this :-(
but it still does not work :
a!localVariables( local!vehicle: rule!TST_GetVehiclesWithFilters( id: 1 ).data[1], local!vehicleUpdateCDT: updatedictionary( dictionary: local!vehicle, /* "cdt" atribute works well too */ fieldsAndValues: { make: "test2" } ), local!vehicle /* sorry variable was incorrect --> local!vehicleUpdateCDT! */ )
Here is the result:
Dictionary