Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Does someone know how to nudge workflow with the Scheduled Script?

IgorMK
Tera Contributor

Hey guyz, 

 

I have a Nudge button on the RITM which works if the Workflow stucks, but I also would like to have a Scheduled Job Script that does for me. 

At the moment it looks like this, but it doesnt work:

IgorMK_0-1721289931980.png

 

If I execute it on Background Script the System give me this message:

IgorMK_0-1721290057783.png

 


Someone know how to access the "SNC.WorkflowScriptAPI()"?

2 REPLIES 2

HIROSHI SATOH
Mega Sage

There have been threads like this in the past.
What is SNC.WorkflowScriptAPI() & Where Can I find it? 

 

We recommend you find an alternative solution or contact our support team.

Satishkumar B
Giga Sage
Giga Sage

Hi @IgorMK 

The error "SNC is not defined" means `SNC.WorkflowScriptAPI()` isn't available in your scheduled job context. Try these solutions:

1. Use GlideRecord: Instead of `SNC.WorkflowScriptAPI()`, use a GlideRecord script to query and nudge stuck workflows directly:

 

 

var gr = new GlideRecord('wf_context');
gr.addQuery('state', 'stuck'); // Modify query as needed
gr.query();

while (gr.next()) {
new Workflow().restartWorkflow(gr);
}

 

 

 

2. Script Include: Create a Script Include for the nudge logic and call it in both your UI action and scheduled job.

 

……………………………………………………………………………………………………

Please Mark it helpful 👍and Accept Solution✔️!! If this helps you to understand.