Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Unable to implement lookup record and for each loop on list collector variables in flow designer

Swarnarghya
Tera Expert

I have a record producer with 3 variables: 
Base CI List: (Refers to cmdb_ci table) - List collector
Child CI List:(same as above) - List Collector
Relationship Type:(refers to cmdb_rel_type table) - Ref field

Once request is submitted, it will go for an approval and a relationship will be created in cmdb_rel_ci table automatically.

 

I have implemented this using flow designer. I created a custom action which converts the list of CI record present in base ci and child ci variables in an array of object. Please refer to error logs

Swarnarghya_0-1684326625564.png

Then I used For each item and lookup record and extracted the sys_ids from them:

Swarnarghya_1-1684326711399.png

Child CIs:

 

Swarnarghya_3-1684326847428.png

 

Parent CI:

Swarnarghya_4-1684326880212.png

But I am unable to proceed how to create a relationship between the child and parent in cmdb_rel_ci table?

 

 

 

2 REPLIES 2

Kristen Ankeny
Kilo Sage

You'll have to nest your for-each loops since you're dealing with two arrays. So if you start with the child, you're saying for each child, interate through the parent(s), and then you can use a create record in the cmdb_rel_ci table for the current child-parent combo inside the nested parent for each loop.

I wrote for each first for child as below:

Swarnarghya_0-1684328292040.png

but when I am iterating the second loop for parent by clicking on (+) and trying to add the parent objects in for each, it says, object not allowed