- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2019 12:27 AM
i want to change the read only field value through background script? please share me script
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2019 12:32 AM
Sample Update code:
var gr = new GlideRecord('incident');
gr.get('06743b65dbe277c0e4d95740cf9619c5'); //SYSID OF THE RECORD.
gr.short_description ='Test'; //assuming short description is read only field
gr.update();
Note: this is sample code to update the record column.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2019 12:29 AM
which value you want to change? On which table?
Example:
var grCI = new GlideRecord('cmdb_ci');
grCI.addQuery('name','=','SAP WEB03');
grCI.query();
gs.print('grCI Query: ' + grCI.getEncodedQuery() + ' = ' + grCI.getRowCount());
while (grCI.next()){
grCI.asset_tag='ServiceNow ';
grCI.update();
}
Refeence:
https://developer.servicenow.com/blog.do?p=/post/training-scriptsbg/
https://developer.servicenow.com/blog.do?p=/post/training-scriptsbg/
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2019 12:32 AM
Sample Update code:
var gr = new GlideRecord('incident');
gr.get('06743b65dbe277c0e4d95740cf9619c5'); //SYSID OF THE RECORD.
gr.short_description ='Test'; //assuming short description is read only field
gr.update();
Note: this is sample code to update the record column.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2019 12:32 AM
Hi,
You can try this after replaceing table and field names.
var gr = new GlideRecord("You table name here"); //Replace table name here
gr.get("SYS_ID_OF_RECORD"); //Replace with sys_id of your record
gr.field_name = "value"; //Replace with field name and required value in here
gr.setWorkflow(false);
gr.update();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2019 12:33 AM
Navigate to Background Scripts:
var inc = new GlideRecord('incident'); // Give the table name
inc.get('SYSID OF the Record you want to change');
inc.short_description = "Give the value you want to Change"; // Give the Field name
inc.setWorkflow(false);
inc.update();
Regards,
Abdul Azeez
Mark Helpful / Correct based on the impact