Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Suggested Answer
+1
person also asked this
people also asked this
Replies
3 replies
Answers
1 answer
Subscribers
8 subscribers
Views
2515 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
Does anyone know how to populate a CDT array from one or more arrays
corbinp505
over 9 years ago
Does anyone know how to populate a CDT array from one or more arrays via dictionary syntax?
For example, I want to generate:
{'type!{myNamespace}MY_Cdt'(first: 1, second: "A"),
'type!{myNamespace}MY_Cdt'(first: 2, second: "B"),
'type!{myNamespace}MY_Cdt'(first: 3, second: "C")}
From these arrays:
firstArray: {1,2,3}
secondArray: {"A","B","C"}
I've tried the following syntax, but it just stores the arrays in a scalar CDT:
'type!{myNamespace}MY_Cdt'(first: firstArray, second: secondArray)
My work around right now is to create a rule that assigns values to a scalar CDT and then run an apply() over the arrays.
I'd rather populate the CDT dynamically without the extra rule if possible.
I appreciate the help and have included the code in the attached file for ease. Thanks.
populateCdtArray.txt
OriginalPostID-143870
OriginalPostID-143870
Discussion posts and replies are publicly visible
Top Replies
Conor Cahill
over 9 years ago
+1
suggested
Certified Lead Developer
have you tried the following? apply( 'type!{myNamespace}MY_Cdt'( first: _, second: _ ), merge( firstArray, secondArray ) )
+1
Conor Cahill
Certified Lead Developer
over 9 years ago
have you tried the following?
apply(
'type!{myNamespace}MY_Cdt'(
first: _,
second: _
),
merge(
firstArray,
secondArray
)
)
Cancel
Vote Up
+1
Vote Down
Sign in to reply
Verify Answer
Reject Answer
Cancel
0
corbinp505
over 9 years ago
That works and gets rid of the extra rule. Thanks Conor!
I'd still be curious if there is a way of doing it without using an apply().
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sikhivahans
over 9 years ago
Other way of achieving the same with out apply is as follows (provided that 'CDT Manipulation' plugin is already installed):
load(
local!myCDTVar:repeat(length(firstArray),type!MY_Cdt()),
updatecdt(local!myCDTVar,{first:firstArray,second:secondArray})
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel