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

Hi Sree,



Can you please see if you see the "correct answer" button now?



Thanks,


I logged out and logged in , still i dont see it


Can you try with different browser and open the thread in new tab.


Opened in a different browser , I GOT THE "Correct answer" button , in the new post ,where I just did . But its not working in this one . Its weird


Thanks Sree for the update. Dan will be helping you out with this request.