Sohail Khilji
Kilo Patron
Options
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 04-18-2024 02:00 AM
Thinking on How to Bulk Update Template field values
Template values are stored as an encoded query, you can do mass update using script. Please refer below script as reference:
Sample script :
var grr= new GlideRecord('sys_template');
grr.query();
while(grr.next())
{
grr.template += '^active=true';
grr.update();
}
Advance Script :
var encodedString = '^u_template_applied_by=javascript:gs.getUserID()^u_template_used=';
var grTem = new GlideRecord('sys_template');
//grTem.addQuery('sys_id', '692c6a13dbd4ef0048f171efbf961983'); // Add more query lines to restrict just to templates that need updating
grTem.addQuery('global', true).addOrCondition('group', '!=', '');
grTem.query();
gs.print(grTem.getRowCount()); // Print out the number of records being updated
while (grTem._next()) {
gs.print(grTem.template);
grTem.template = grTem.template.replace('^EQ', '') + encodedString + grTem.name.toString() + '^EQ';
grTem.setWorkflow(false); // Don't run business rules, etc.
grTem.autoSysFields(false); // Don't update system fields
//grTem.update(); // Un-comment this line once you're sure the row count is just the records you want to update.
}
<<< Top Articles >>>
- ServiceNow Integration with Splunk
- LDAP Integration with ServiceNow
- ServiceNow Integration with Veeam
- Handling ServiceNow flow errors with a flow
- Show parent child incident relationships - display in field message
- ServiceNow SSO Logout Error (redirects to logout page) – Reason, Fixes and Cause.
- Multi Row Variable set ServiceNow MRVS - Creating - Scripting - Example - Limits
- ServiceNow Integration with MAC vendor - Get Mac vendor for the given MAC Address.
- How to find Log4j vulnerable severs in ServiceNow Using CMDB Query Builder (SecOps)
- How to Cancel a Long-Running Transaction ServiceNow
- Hidden Features for System Administrators
- Servicenow RPA - Understanding Attended / Unattended / Skilled Automation Bots
- Servicenow vCenter Discovery | Step by step Discovering VMware using vCenter Discovery.
- Set Discovery Schedule name to CMDB Record (via Discovery)
- Step by Step - How to discover Linux Servers in ServiceNow
- How to Generate PDF from UI action.
- Servicenow Discovery Implementaion Requirement Gathering & Pre-requisites.
MF Sohail Khilji | Servicenow Developer / Consultant.
Connect On LinkedIn > https://www.linkedin.com/in/mf-sohail-khilji/
Labels: