- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 03-02-2018 12:03 AM
One can create a change request template to create pre-defined supporting tasks as explained in the link below:
But for this approach, one should create a module and on clicking the module a new change change request gets created with the predefined tasks.If the template is selected from toggle-bar of an existing change-request,tasks will not be created.Also, in some cases, new change request will be created with predefined tasks.
Here is the solution for the aforementioned problem
Create a reference field on change request ,pointing to Template table.
Configure an on change client script on change request as shown below:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if(!isTemplate)
var usrtemplate = g_form.getReference('u_template', changefields); // changefields is our callback function
}
function changefields(temp) { //reference is passed into callback as first arguments
if (temp.sys_id != '')
applyTemplate(temp.sys_id);
}
However,this client script will only populate fields on the form with the values derived from template.It will not create change tasks.
Configure an on after business rule on 'Change_request' table as shown below,so that pre-defined tasks are created:
(function executeRule(current, previous /*null when async*/) {
var tempName = current.u_template;
var ltemplate = new GlideTemplate.get(tempName);
if (ltemplate)
{
current.setNewGuidValue(current.sys_id.toString()); // this is necessary to keep the template code from setting a new sys_id value for the record
ltemplate.setDoInsert(false); //To prevent insertion of a duplicate record
ltemplate.apply(current); //To apply template for Change Request
}
})(current, previous);
Here u_template is the reference field on change request pointing to Template table. When user selects a template from this reference field, the respective template will be applied on the existing change request with predefined tasks created. This will also be helpful when there are too many templates for change request, as selecting them from toggle bar won't be feasible.
Thanks!
- 4,736 Views