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 } )
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
you're using "updatedictionary()" but then passing it a property named "cdt" instead of "dictionary". This would cause it to assume that the input dictionaryis blank, which is approximately what we're seeing from your output.
Sorry Mike, it was an error, of course, I've tested before with the "dictionary" field name.
I have edited my previous post.
oh, also - at the end of your example code you're only outputting the value of local!vehicle, not of local!vehicleUpdateCdt - so we would expect the output you're seeing to only be the original and not the updated version.
Instead your code should look like this:
a!localVariables( local!vehicle: rule!TST_GetVehiclesWithFilters( id: 1 ).data[1], local!vehicleUpdateCDT: updatedictionary( dictionary: local!vehicle, fieldsAndValues: { make: "test2" } ), local!vehicleUpdateCDT )
I'm re-sorry Mike, my previous post was sent too quickly (I've re-edited my previous post).
Thank you, all works fine, but I confirm you that the old "cdt" attribute works well, anyway I have to use the new one.
Stefan, thank you very much for your help. "data[1]" saved my life ;-)
- A last question, if you would not have this plugin, how would you do ?
you would enter the 50 fields of the CDT and update the only one value to change ?
Using the plugin is the way to go. I am talking to Appian for quite a while to get this function into the product. There is no environment I have ever seen where this is not deployed. In the end, this is what plugins are for and it works pretty well.
Thanks a lot for your reply Stefan. Yes of course, that makes sense and we already use it for our customers.
cedric01 said:if you would not have this plugin, how would you do ?
It would be a total pain in the butt and require unreasonable workarounds. In the old days before this plug-in was stable, we just had to be very careful to structure our implementations in such a way that we didn't end up needing it (which is also a pain in the butt).
Very interesting...thank you for your feedback.