The CreatorCon Call for Content is officially open! Get started here.

How to Trigger the SLA from workflow only and does not trigger like normal SLA Definition works

varshajain
Tera Expert

I create one SLA definition and want to trigger it through workflow only . But it trigger it from SLA definition , want to make it disable .
and to trigger SLA from workflow, I follow these script but it didn't work

(function() {
    var slaDefinitionId = '39701a5b3b7ba214b179dd24c3e45a14'; // Replace with actual SLA Definition sys_id
   
    var controller = new TaskSLAController(current);

    // Start the SLA
    controller.startSLA(slaDefinitionId);

    gs.info("SLA manually triggered for record: " + current.getDisplayValue());
})();


9 REPLIES 9

Not that I'm aware, as it's not intended functionality.

 

You could potentially call TaskSLA directly, which is the script include which TaskSLAController invokes. But I've never tested the functionality to know the impact it might have on wider SLA calculations.

 

// new TaskSLA(contractSLAgr, taskGR)
	//  -- add a new task_sla GlideRecord, related to the taskGR GlideRecord, based upon the contractSLAgr GlideRecord
	//     (assumes the caller has already made the decision to add it, and is actively preventing
	//     multiple overlapping requests to add the same contract_sla)
	//

Ankur Bawiskar
Tera Patron
Tera Patron

@varshajain 

Why to do this?

Why not stick to OOTB process and let instance handle the trigger of SLA based on Start condition?

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

Because the start conditions which I want to configure can't be possible in OOTB Start condition.
That 's why I created those conditions in workflow, and now i want to trigger it.

@varshajain 

on what condition the SLA should start?

share those

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

1. When Person added in particular Azure AD Group
2. One field in catalog , delivery date is less than 5 days from today.

3. Once 4 approval get approved.

4. Weekend should not be counted in that 5 days.

5. When user is adding in particular AD Group, checks Schedule Delivery date should be 7 days more than requested delivery date.