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.

For Each Data Pill is always undefined inside Script

PaKe
Kilo Sage

Hey,

 

I want to set a flow variable via script with the value from a "For Each"-Item. When I use the data pill I retrieve the correct value. When I want to use a script I always retrive "undefined".

The "Set Flow Variables"-Action is inside the "For Each"-Loop.

 

Where is my problem?

 

PaKe_0-1748597825828.pngPaKe_1-1748597858774.png

 

19 REPLIES 19

@PaKe 

so that's the issue I believe, since you are in custom scope it may not be allowing you to have read access to that table and field

I will suggest to add cross scope privilege record for those child table 1 by 1

OR

You can also use a script to populate those at bulk

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Chaitanya ILCR
Mega Patron

Hi @PaKe ,

 

do you have two flow variables with names

msgsuccessful and msgSuccessful?

 

if you only have one variable I think there is a typo S  in msgSuccessful should be caps

 

if you have 2 variables what the first one's(msgsuccessful) value

 

does the ci_item has correlation id populated?

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

Hey @Chaitanya ILCR,

 

no there is no typo. If I do it like that, the script works.

PaKe_0-1748599642586.png

 

Hi @PaKe ,

 

check the field names are correct

 

"ci_item" on the lookup records table

do you have ci_item field on the table that you are using on the lookup records action?

if yes

do you have correlation_id field on the ci_item (field referring table) ?

 

 

in the return statement you can just use "+" instead of "+=" ( this is not the issue)

 

this should be because field doesn't exit on the table (either ci_item or correlation_id) 

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

CI Item Field is referring "cmdb_ci"-Table which has a field "correlation_id". I don't know where the problem is.

 

I used the same script on my PDI and it worked