- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2020 09:25 AM
Hi All,
In a UI action on the sc_task table I am calling the following script to create a standard change:
createChange: function(template, templateID) {
var dates = this.calculateDates();
var createChng = new GlideRecord('change_request');
createChng.initialize();
createChng.type = 'standard';
createChng.start_date = dates.start_date;
createChng.end_date = dates.end_date;
createChng.std_change_producer_version = templateID;
createChng.applyTemplate(template);
createChng.insert();
return createChng;
},
This is setting most of the fields from the standard change template apart from 'description, short_sescription' & u_service' fields. Having a bit more a look into this, these 3 fields are the only fields from the template which we don't have in the 'read only' property under the standard change properties. If I add them to this property then re-run the script it creates a standard change and sets these 3 fields.
Any help on why when the 3 fields are not included in the read only standard change property they do not get applied?
I have checked and if I manually select the template from the standard change catalog and the fields are not in the red only property they still get set, it seems to only be when using the script?
Thanks
Sam
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2020 04:50 PM
I reached out to HI in the end with the issue being with the business rule 'Apply standard change template'. This is a display business rule, so does not run when trying to set the template from a script (manually selecting the template takes you to the record to submit).
I had to replicate the logic in the business rule within my script
Hope this helps
Thanks
Sam

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2020 09:32 AM
HI,
yes there is a business rule which does the check for this readonly variables.
Restrict fields from Standard Change
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2020 09:52 AM
Hi Ashutosh,
We had a previous issue with fields not setting as we expected, and following a Hi ticket they advised us to set the 'two step' property to true advising that when the property is set to false then the 'Restrict fields from Standard Change' gets called, but when set to true the rule is not called. We have 'Two step' property set to 'true'.
Is the above not the case when calling the template from a script?
What would be the best way around this?
Thanks
Sam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2020 01:36 AM
Hi,
I've set the business rule 'Restrict fields from Standard Change' to false and then ran my script and it then creates the standard change without setting any of the fields.
I've set it back to true so it still populates all the read only fields, but I need to figure out how to make the 3 non read only fields set with the data from the template?
Thanks
Sam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2020 04:50 PM
I reached out to HI in the end with the issue being with the business rule 'Apply standard change template'. This is a display business rule, so does not run when trying to set the template from a script (manually selecting the template takes you to the record to submit).
I had to replicate the logic in the business rule within my script
Hope this helps
Thanks
Sam