Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Sohail Khilji
Kilo Patron

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.
}
Version history
Last update:
‎04-18-2024 02:00 AM
Updated by:
Contributors