Fix script to add 3 user in a field

Deo Christian V
Tera Contributor

DeoChristianV_0-1745542670209.png

Need a fix script to add 3 users in Co-managers field in a group

11 REPLIES 11

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:

RobertH_0-1745563583757.png

RobertH_1-1745563727032.png

 

Regards,

Robert

Ankur Bawiskar
Tera Patron
Tera Patron

@Deo Christian V 

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.

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