- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2025 02:01 PM
Hello,
when i used background script i am getting multiple rows and at the same time when i used script include i am getting only one value instead of multiple values, and the field i used on the form is a list collector. script as follows:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2025 12:48 AM
Hello @Kumar147 ,
The problem is at line return chgList.join(',');
this return statement should be out of while loops. In script execution, once return statement read, blocks are automatically terminated. In your script return statement was written in while loops. So, loop terminated at the first iteration, because it reads return statement.
Try the same script with return statement after loops.
Thank you
G Ramana Murthy
ServiceNow Developer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2025 02:22 PM
Hi @Kumar147 ,
From the code and snap from sys log it determines that there are four records found in table one. Now out of four table one record (dependent change) there is only one record found in table two. That’s why only one record is viable in the log dependent task1 which you are returning.
Pls correct me if I have miss understand your e.g.
If my understanding is correct then where is the issue?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2025 02:50 PM
Hello @Rohit Singh
from background script i am getting four records
in a row, but from script include i am able to get only one record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2025 03:09 PM
Hi @Kumar147
Four records from table one? Screenshot which you have shared is from Sys log table. Those values in sys log are captured when you have executed background script?
can you make sure in this line of code rls.addQuery('number', relChg); you are using same sys_id in both background script and script include for testing?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2025 12:39 AM
Hi @Rohit Singh
I am using same sys_id in both background script and script in include. I got four rows in background script. Log is from script include and background script gives in rows