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
5 replies
Subscribers
7 subscribers
Views
2041 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
Hi I have two arrays , one for the #MaterialCode and one for the #SerialNumbers
danielem
over 9 years ago
Hi I have two arrays , one for the #MaterialCode and one for the #SerialNumbers
Arrays are alrady sorted.
what I need to obtain is an array of [#MaterialCode,#ListofSerialNumber] list of serial Numbers for each #MaterialCode
Example:
#MaterialCode : {083813291400, 083813291400, 083813291400, 083816316600, 083816316600}
#SerialNumbers: {BB, DD, EE, XX, YY}
Desire Output should be:
{
{083813291400,"BB,DD,EE"},
{083816316600, "XX , YY"}
}
Thank you in advanced
OriginalPostID-153181
OriginalPostID-153181
Discussion posts and replies are publicly visible
Parents
0
Amitkumar
over 9 years ago
This can be done easily by creating two expression rules. Parent rule will have to do apply on other another rule to format material code and serial numbers. First thing, material codes are too big for an integer data type. So, I converted them into text data type and formatted them desired output that you need.
Here is the code that you can take a look. You can add more exception handling, and pass different list of input to local variables.
Main rule :
load(
local!materialCodes :{"083813291400", "083813291400", "083813291400", "083816316600", "083816316600"},
local!serialNumbers:{"BB", "DD", "EE", "XX", "YY"},
apply(
rule!formatMaterialCodeAndSerialNumbers,{union(local!materialCodes,local!materialCodes)},local!materialCodes,local!serialNumbers)
)
Rule : formatMaterialCodeAndSerialNumbers
{ri!int_materialCode,
joinarray(
index(ri!text_listOfSerialNumbers,
fn!wherecontains(tostring(ri!int_materialCode),apply(fn!tostring,ri!int_listOfMaterialCodes)),""),",")
}
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Reply
0
Amitkumar
over 9 years ago
This can be done easily by creating two expression rules. Parent rule will have to do apply on other another rule to format material code and serial numbers. First thing, material codes are too big for an integer data type. So, I converted them into text data type and formatted them desired output that you need.
Here is the code that you can take a look. You can add more exception handling, and pass different list of input to local variables.
Main rule :
load(
local!materialCodes :{"083813291400", "083813291400", "083813291400", "083816316600", "083816316600"},
local!serialNumbers:{"BB", "DD", "EE", "XX", "YY"},
apply(
rule!formatMaterialCodeAndSerialNumbers,{union(local!materialCodes,local!materialCodes)},local!materialCodes,local!serialNumbers)
)
Rule : formatMaterialCodeAndSerialNumbers
{ri!int_materialCode,
joinarray(
index(ri!text_listOfSerialNumbers,
fn!wherecontains(tostring(ri!int_materialCode),apply(fn!tostring,ri!int_listOfMaterialCodes)),""),",")
}
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Children
No Data