Fix script to add 3 user in a field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2025 05:58 PM
Need a fix script to add 3 users in Co-managers field in a group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2025 11:49 PM - edited ‎04-24-2025 11:49 PM
Hello @Deo Christian V ,
On top of the things that @Kieran Anson and @Ankur Bawiskar mentioned, I would like to understand the overall objective.
Looking at your script it seems to check for Groups that start with "Billing team", then takes ONE of them randomly and populates its "Co-Manager" field. So if you have more than one Billing team group you'll might not get the result you're expecting. You would need to remove the "setLimit(1)" line and replace the "if (gr.next))" with "while (gr.next())".
And in fact, you would not need a script at all. For such a simple task you could just use a Data Management job:
Regards,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2025 08:02 PM
We don't know your business requirement.
Please share it and the script you tried and what's the expected outcome (screenshots)
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