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
1688 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
Hi, I'm having a few issues getting an expression which can obtain data from
jarrods229
over 9 years ago
Hi, I'm having a few issues getting an expression which can obtain data from a 2nd tier of nested objects.
Essentially I have a collection of "Parents" where the data for children can be described using ad-hoc data structure as:
= {
{
ParentName: "Amanda",
children: {
{
Child: {
ChildName: "Emma"
}
},
{
Child: {
ChildName: "Abi"
}
}
}
},
{
ParentName: "Kyle",
children: {
{
Child: {
ChildName: "Ethan"
}
}
}
}
}
What I'm after is an array of text values for all the ChildNames - but I can't seem to make use of the apply, merge or union functions to achieve this. Any Ideas?...
OriginalPostID-124332
OriginalPostID-124332
Discussion posts and replies are publicly visible
Parents
0
Michael Chirlin
Appian Employee
over 9 years ago
To do that you will need two rules. The inner rule will put out the child names from each parent and the outer rule will apply that inner rule to each parent. It will look like this:
***PARENT RULE***
with(
local!data: {
{
ParentName: "Amanda",
children: {
{
Child: {
ChildName: "Emma"
}
},
{
Child: {
ChildName: "Abi"
}
}
}
},
{
ParentName: "Kyle",
children: {
{
Child: {
ChildName: "Ethan"
}
}
}
}
},
apply(
rule!Child_Rule,
enumerate(length(local!data)) + 1,
local!data
)
)
***CHILD RULE***
Inputs:
index (int)
data (any type)
index(index(index(index(ri!data, ri!index,""), "children", ""), "Child", ""), "ChildName")
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Reply
0
Michael Chirlin
Appian Employee
over 9 years ago
To do that you will need two rules. The inner rule will put out the child names from each parent and the outer rule will apply that inner rule to each parent. It will look like this:
***PARENT RULE***
with(
local!data: {
{
ParentName: "Amanda",
children: {
{
Child: {
ChildName: "Emma"
}
},
{
Child: {
ChildName: "Abi"
}
}
}
},
{
ParentName: "Kyle",
children: {
{
Child: {
ChildName: "Ethan"
}
}
}
}
},
apply(
rule!Child_Rule,
enumerate(length(local!data)) + 1,
local!data
)
)
***CHILD RULE***
Inputs:
index (int)
data (any type)
index(index(index(index(ri!data, ri!index,""), "children", ""), "Child", ""), "ChildName")
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Children
No Data