Updating the value of certain field in a number of records from User table using Background Script

Appu2
Tera Contributor

Hi, Need help in writing the background script!

Below is the requirement:

I have a custom table which has a Country field in it and it is populated based on user selected in the field Engagement Partner and my requirement is to update the Country field value in this custom table for a number of records by searching the the user from "User" table and picking up the value of Country from User table and updating the value into Country field in custom table.

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@Appu2 

please share what script did you start with and where are you stuck?

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

@Ankur Bawiskar 

I am not able to understand how to start with it!

@Appu2 

unless you start how will you learn

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

@Appu2 

Here are the steps to design the script to fulfill your requirement

  1. "GlideRecord" the custom table you created
  2. Add the "encodedQuery" as per your requirement the "Query' it
  3. Within the while loop, query the sys_user table with the encodedQuery of sys_id=u_engagement_partner, and then query it
  4. Get the value of the country field set that value in your custom table field and then update it.

Would you mind designing a script and come back to here, will help you then.

 

Best Regards,

Tarun