Hi ,
local!dataset: cast( 'type!{urn:com:appian:types}HistoryV', local!datamaster.data ) , I
n above code only first row is getting cast to new data type.
Ideally it should ocnvert whole dataset.
Kindly share your inputs on that . How can i convert whole dataset
Discussion posts and replies are publicly visible
Try like
cast('type!{urn:com:appian:types}HistoryV?list',local!datamaster.data)
or
cast(typeof({'type!{urn:com:appian:types}HistoryV'()}),local!datamaster.data)
By way of explanation to post above, a thing and a list of that thing are two entirely different datatypes. When you cast a list as a singular datatype, Appian assumes that means you only want the first element in the single type. That's why you can solve by enclosing the same type constructor in curly brackets, making a thing into a 1-length list cointaining that thing.
I frequently have to do cast(typeof({1,2}), ri!input) to get integers, and not just an integer.
cast( typeof( { 'type!{urn:com:appian:types}HistoryV'() } ), local!datamaster.data)
What you are missing is {}, the type! should be declare inside the curly braces to convert is of type HistoryV with multiple.
This answer was very robust cast('type!{urn:com:appian:types}HistoryV?list',local!datamaster.data)
It worked for me. I just added "?list" n it converted whole dataset.
That appears to work. I've always been confused trying to use the "?list" approach, because when using the type! (and autocomplete) in Appian, it by default adds "()" at the end, which from your example would be like <<'type!{urn:com:appian:types}HistoryV?list'()>> - which works without the "?list" part added, but breaks when trying the list version. It turns out that simply removing the "()" makes it work. Thanks for posting the clarification.
If it helps:
'type!{urn}XXX_Type'() generates an INSTANCE of the type in question
'type!{urn}XXX_Type' creates a REFERENCE to the type (e.g. for CASTing purposes)
Adding the '?list' to the latter simply generates a DIFFERENT type (lists of a type are considered as a different types from the base type itself)
In order to generate a list you can use the array modifier:
{ type!{urn}XXX_Type'() , type!{urn}XXX_Type'() }
(this will create an array of 2 instances of the specified type, and the overall array is a different type from the members of the array)