background script to update user information

Kristina2
Tera Contributor

Table : sys_user

I am trying to run a piece of code , its not working , i would like to get people inputs ,

We need a background script to update the Employee Number for all people with a User Brand = "Beta""

to add "Beta:" as a prefix to the existing Employee Number.

So it should display as " Beta: 25467".

Code :

function addPrefix(){

var gr = new GlideRecord("sys_user");

gr.addQuery('sys_id',"bac617ddd56c8104583a92146e8f872a");

gr.addQuery('u_user_brand', 'Beta');

gr.query();

while(gr.next())

{

gr.user_brand = gr.employee_number.replace('Beta:');

gr.update();

}

}

addPrefix();

24 REPLIES 24

dan.bruhn can you assist?


Some users do not see the Correct Answer link (per this video at 20:00 https://community.servicenow.com/thread/224893). Let me know if you do not see it and I can get a community moderation to assist.


Went through the video link Pradeep , I dont see the "Correct Answer button " on my screen and when i drag down actions , "No actions are available "



Thanks for your time


Thank you Sree,



I've tagged on of the community moderators to look in to it. We thought we had this issue resolved.


Thanks Tomasi