Unable to fetch Sla displayvalue/sysid in business rule
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2025 08:58 PM - edited 06-10-2025 09:02 PM
Hello ServiceNow Community
I am trying to write business rule to create new Task sla when Assigned to changes.
As per the below script new Task sla is being created,but the new sla Defnition is showing blank.
I tried hardcoding newSLA.sla value to 'Sys_id' and it worked.I see that sla of initial task sla is not being retreived.I am trying to retreive through .getValue('sla')
Could the community please suggest where would the correction be needed.
Thanks in Advance
(function executeRule(current, previous /*null when async*/) {
// check if assignee has changed
if(current.assigned_to!=previous.assigned_to){
//check if task already has a Task SLA
var slaGR = new GlideRecord('task_sla');
var slaDisplay = slaGR.getDisplayValue('sla');
slaGR.addQuery('task', current.sys_id);
//slaGR.addQuery('task', slaGR.getValue('sla'));
slaGR.query();
if(slaGR.hasNext()){
//create a new Task SLA
var newSLA = new GlideRecord('task_sla');
var slasysid = slaGR.getValue('sla');
newSLA.initialize();
newSLA.task = current.sys_id;
newSLA.sla = slasysid;
newSLA.start_time = new GlideDateTime();
newSLA.stage = 'In Progress';
//newSLA.
newSLA.insert();
}
}
})(current, previous);
6 REPLIES 6
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2025 10:25 PM
why are you creating task_sla via script?
You can configure SLA Definition with correct start condition and system will associate that SLA with your record.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2025 06:47 AM
Hi Ankur
I am writing this script to create new task sla record whenver Assignee changes.New task sla is getting created but I dont sla defniton being popped up