Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
11 replies
Subscribers
8 subscribers
Views
13511 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
Convert to a CDT
Soumya.Behera
over 8 years ago
Hello Everyone,
I have an expression whose output is of type "Any Type (Dictionary)". I want to typecast it into the desired CDT type. Please let me know the method.
OriginalPostID-243301
Discussion posts and replies are publicly visible
Top Replies
sikhivahans
over 8 years ago
+2
Usage of a!applyComponents() is redundant or I should say that it's not needed. The following should be enough as per my knowledge: fn!cast( fn!typeof({type!SSB_IAL_EmployeeDetails()}), a!queryEntity(…
Soumya.Behera
over 8 years ago
+1
In case anyone's wondering what exactly I did, please find attachment for the solution to my challenge. You can mould it to your requirement. solution.txt
0
sikhivahans
over 8 years ago
@soumyab fn!cast(fn!typeof(type!myCdt()),<targetDataset>) for single type and fn!cast(fn!typeof({type!myCdt()}),<targetDataset>) for multiple type(or list) should do the job as per my knowledge.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sikhivahans
over 8 years ago
However, you may also use a variable(local/ri/PV) as well in the place of type! definition provided if you are sure about the data type and multiplicity of the variable.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sparshs
over 8 years ago
yeah you can create a rule which will designate each value from Datasubset to cdt and you cna use that rule inside apply to generate the desired CDT.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Soumya.Behera
over 8 years ago
@sikivahans it worked..thank you
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Soumya.Behera
over 8 years ago
In case anyone's wondering what exactly I did, please find attachment for the solution to my challenge. You can mould it to your requirement.
solution.txt
Cancel
Vote Up
+1
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sikhivahans
over 8 years ago
Usage of a!applyComponents() is redundant or I should say that it's not needed. The following should be enough as per my knowledge:
fn!cast(
fn!typeof({type!SSB_IAL_EmployeeDetails()}),
a!queryEntity(
entity: cons!SSB_IAL_EMP_DETAILS,
query: a!query(
pagingInfo: a!pagingInfo(
1,
-1
)
)
).data
)
On a side note, a!applyComponents() imposes burden as cast function is being invoked in an iterative manner over each record in the data subset. This isn't needed when fn!cast() is able to deal with arrays based on the data type inputted to it.
Cancel
Vote Up
+2
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Soumya.Behera
over 8 years ago
@sikhivahans The way you told is perfectly correct. But, if I remove a!applyComponents from my implementation method then, it will only cast single element. That is why I had to use it. And thanks for the suggestion, I have changed it.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Soumya.Behera
over 8 years ago
@sikhivahans Found a point worth noting. The difference is not with whether we should use fn!cast or simply cast function as both are accepting array parameters. The difference was the way I used typeNumber parameter. If I use fn!typeof({'type!{urn:com:appian:types}SSB_IAL_EmployeeDetails'()}), then it's casting all the elements in the list parameter. On the other hand if I use 'type!{urn:com:appian:types}SSB_IAL_EmployeeDetails' then it's only converting the first element of the array. Hope it helps.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sikhivahans
over 8 years ago
@soumyab That's what I have mentioned in my very first comment, not sure if you have gone through it. For list use curly braces around the data type and for a single type, just use the data type.
Usage of a function with or without fn! doesn't make any difference and it's a different
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sikhivahans
over 8 years ago
*topic.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
>