Unable to fetch Sla displayvalue/sysid in business rule
- 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2025 10:00 PM
Hi @Siddharth Parna ,
try this
(function executeRule(current, previous /*null when async*/) {
// Check if assignee has changed
if (current.assigned_to != previous.assigned_to) {
var slaGR = new GlideRecord('task_sla');
slaGR.addQuery('task', current.sys_id);
slaGR.query();
if (slaGR.next()) {
// Retrieve the SLA sys_id from the existing task_sla record
var slasysid = slaGR.getValue('sla');
// Create a new Task SLA
var newSLA = new GlideRecord('task_sla');
newSLA.initialize();
newSLA.task = current.sys_id;
newSLA.sla = slasysid;
newSLA.start_time = new GlideDateTime();
newSLA.stage = 'In Progress';
newSLA.insert();
}
}
})(current, previous);
but you can the condition in the SLA definition it self that if assigned to changes attach the sla
this is the right approach
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2025 06:44 AM
I tried this script but I still I see the new sla defnition showing empty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2025 10:13 PM
Hello @Siddharth Parna,
current.sla
field directly returns the sys_id of the SLA record, not the human-readable display value. To get the display value, you need to use the getDisplayValue()
method on the current.sla
object.
getDisplayValue()
- Instead of
current.sla
, usecurrent.sla.getDisplayValue()
to access the display value of the SLA.
(function executeRule(current, previous /*null when async*/) {
// Get the display value of the SLA
var slaDisplayValue = current.sla.getDisplayValue();
// Use the display value in your logic (e.g., logging, updating fields)
gs.log("SLA Display Value: " + slaDisplayValue);
})(current, previous);
- If you need other details from the SLA record besides the display value, you can query the
sla
table usingGlideRecord
(function executeRule(current, previous /*null when async*/) {
// Get the display value of the SLA
var slaDisplayValue = current.sla.getDisplayValue();
// Get the SLA record itself
var slaGR = new GlideRecord('sla');
slaGR.addQuery('sys_id', current.sla); // Assuming 'current.sla' contains the sys_id
slaGR.query();
if (slaGR.next()) {
// Access other SLA attributes
var slaName = slaGR.name; // Example: Get the SLA name
var slaDescription = slaGR.description; // Example: Get the SLA description
gs.log("SLA Display Value: " + slaDisplayValue + ", SLA Name: " + slaName);
}
})(current, previous);
getDisplayValue()
and querying the sla
table when needed, you can ensure you have the correct information for your business rule logic.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2025 06:42 AM
I tried this approach but still I dont see sla defnition being mapped for the new sla created