- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2024 12:15 PM
Hello all. I have a background script created to update values on pretty much all of our templates in the system. However, we would like to add a field to all of the templates and populate the value of the field without having to go into each template manually. In the script below I'm trying to update the 'u_template' field with the value from the 'name' field (long story so don't ask haha) but since the u_template field isn't in any of the templates, it's not actually updating the record. Is there a way I can add the u_template field to the templates without doing it individually? TIA
// Create a new GlideRecord instance for the sys_template table
var templateGr = new GlideRecord('sys_template');
var count = 0;
// Add a condition to filter active templates where the global checkbox is false
templateGr.addQuery();
templateGr.addQuery('active', true);
templateGr.addQuery('global', true);
// Execute the query
templateGr.query();
// Loop through the results
while (templateGr._next()) {
count++;
//templateGr.global = true; // Was previously used to set the global vlue to true
templateGr.u_template = templateGr.name; // Set the template name field to the name of the template
templateGr.update(); // Update the record
gs.info('Template name: ' + templateGr.name);
gs.info('Template name: ' + templateGr.u_template);
}
gs.info(count);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2024 09:14 AM
According to support, this is not possible:
"Thank you for your update. I have checked this further internally and also with a team lead and unfortunately, there is no ServiceNow API that is able to achieve the functionality you are looking for.
We apologize for the inconvenience this may cause. As mentioned previously if you think this can be a useful functionality, then we recommend creating an enhancement request
We have moved this case to the solution proposed state. Please let us know if you have any additional questions. Otherwise, you may accept the solution and bring the case to a close. "
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2024 11:14 AM
There may be ACLs or dictionary overrides stopping you. SN Support will be able to help you. you can review the node log after testing to possibly get some insight.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2024 11:25 AM
This also isn't working in an OOB instance so I don't think this is something specific to our instance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2024 02:02 PM
did you run the script logging in as 'admin' user? That is how I tested your logic. I got one failure due to Application Scope restrictions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2024 09:12 AM
According to support, this is not possible:
"Thank you for your update. I have checked this further internally and also with a team lead and unfortunately, there is no ServiceNow API that is able to achieve the functionality you are looking for.
We apologize for the inconvenience this may cause. As mentioned previously if you think this can be a useful functionality, then we recommend creating an enhancement request
We have moved this case to the solution proposed state. Please let us know if you have any additional questions. Otherwise, you may accept the solution and bring the case to a close. "
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2024 09:14 AM
According to support, this is not possible:
"Thank you for your update. I have checked this further internally and also with a team lead and unfortunately, there is no ServiceNow API that is able to achieve the functionality you are looking for.
We apologize for the inconvenience this may cause. As mentioned previously if you think this can be a useful functionality, then we recommend creating an enhancement request
We have moved this case to the solution proposed state. Please let us know if you have any additional questions. Otherwise, you may accept the solution and bring the case to a close. "