JavaScript Executor Question

jmuomini
Mega Expert

Hi,

I'm trying to run the script below using the JavaScript Executor (Ctrl-Alt-Shift-J). Nothing happens when I click "Run my code." Is something wrong with the code, or is this not the right place to run it?

Thanks, JiM


<script>
//Generic Incident update script. Update query and update lines
var gr = new GlideRecord('incident');
gr.addQuery('u_source','Walk-in');   //Change query to field being updated
//gr.addQuery('u_subcategory','USFwebsite');
//gr.addQuery('field','value');
gr.query();
while (gr.next()) {
     gr.u_category = 'LMN Walk-in';     //Change to field being updated
     gr.setWorkflow(false);
     gr.autoSysFields(false);
     gr.update();
}
</script>
7 REPLIES 7

Mark Stanger
Giga Sage

That's a client-side functionality. You're running some server-side code there. If you need to run server-side code you can use the 'Scripts-Background' module or an on-demand scheduled job.


Thanks Mark


Hi,


How can i go to scripts background.


is there any short cut.


can u please help me with this.


Hi Ashutosh,



To access the Scripts - Background, you have to log in as admin and then click the lock icon at the right of the message Welcome System Administrator (in the top of the home screen) to get elevated privileges. Once you select security_admin privileges, you find the Scripts - Background in the application menu under System Definition.