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
9 replies
Subscribers
7 subscribers
Views
1806 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
General
Can any one help on this I need a function or a logic which gives expected outpu
RAAS INFOTEK LLC
over 8 years ago
Can any one help on this I need a function or a logic which gives expected output from two arrays.
each variable from array1 should map with all variables in array2.
{a,b} {c,d,e} output (a,c)(a,d)(a,e)(b,c)(b,d)(b,e)
{a} {b,c,d} output (a,b)(a,c)(a,d)
Thanks
OriginalPostID-210308
OriginalPostID-210308
Discussion posts and replies are publicly visible
0
Stefan Helzle
A Score Level 3
over 8 years ago
You create one helper expression
HelperEx(value(any), list(any)):
=merge(
repeat(length(ri!list), ri!value),
ri!list
)
Calling:
=apply(
rule!HelperEx(
value: _,
list: {"c", "d", "e"}
),
{"a", "b"}
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
RAAS INFOTEK LLC
over 8 years ago
Thanks @stefanh791 but I would like to use that combination as list in apply function to insert into two different fields. could you suggest how can I achieve.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 8 years ago
I am not sure what you want to do. Maybe you explain it a bit.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
RAAS INFOTEK LLC
over 8 years ago
apply(
fn!ex(
list1:_,
list2:_,
),
{I need to generate expected output here from list1 and list2(as mentioned above)}
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 8 years ago
OK. Lets try this. I had to add another helper expression. This returns a true list of value pairs. I hope this is what you want.
BuildValuePair(value1(any), value2(any)):
={ri!value1, ri!value2}
HelperEx(map(any), list(any), value(any)):
=append(ri!map, apply(
rule!BuildValuePair(
value1:_,
value2:_
),
merge(
repeat(length(ri!list), ri!value),
ri!list
)
))
Call:
reduce(
rule!TS_TestExpression(
map:_,
value: _,
list: {"c", "d", "e"}
),
{},
{"a", "b"}
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
RAAS INFOTEK LLC
over 8 years ago
Sorry @stefanh791 I am getting same o/p as above I will explain a bit clearly.
Exp(empId(num(int))array,courseId(num(int))array)
apply(
'Test_table'(
empId:_,
courseId: _,
createdOn: now(),
createdBy: loggedInUser()
),
{ri!empId,ri!couseId}---each employe should register with all courses and i have Insert them into db.
)
for ex: empId{1,2} courseId{22,33,44}
Expected output:
[empId=1, courseId=22,createdOn=5/6/2016 3:35 PM EDT, createdBy=ramuk];
[empId=1, courseId=33,createdOn=5/6/2016 3:35 PM EDT, createdBy=ramuk];
[empId=1, courseId=44,createdOn=5/6/2016 3:35 PM EDT, createdBy=ramuk];
[empId=2, courseId=22,createdOn=5/6/2016 3:35 PM EDT, createdBy=ramuk];
[empId=2, courseId=33,createdOn=5/6/2016 3:35 PM EDT, createdBy=ramuk];
[empId=2, courseId=44,createdOn=5/6/2016 3:35 PM EDT, createdBy=ramuk]
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 8 years ago
OK. Then you can just modify the BuildValuePair expression to create the required data structure. Something like
='type!{urn:com:xxx:types:yyy}Your_Course_Type'(
empId: ri!value1,
courseId: ri!value2,
createdOn: now(),
createdBy: "ramuk"
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
RAAS INFOTEK LLC
over 8 years ago
Thanks @stefanh791 it worked :)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 8 years ago
This is good news. I am happy I could help you.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel