For Each Data Pill is always undefined inside Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2025 02:37 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2025 02:39 AM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2025 03:02 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2025 03:07 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2025 03:33 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2025 03:47 AM
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