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.

Workflow with Trigger "Service Catalog" but Simulate Service Request - Submission with Scheduled Job

lhoang
Tera Contributor

Hi All,

Like the subject already says it:

I have a Workflow with a Trigger "Service Catalog" - this flow works perfectly fine using the catalog item and submitting a request.

Now I need to simulate/fake such a service request submission (depending on an automatic script schedule).

This script also works. A request and request item is created after executing the schedule. But the Workflow won't.

Do you have any tipps?

1 REPLY 1

Nicholas_Gann
Mega Guru

Without seeing the script you're using to generate the REQ & RITM I'm not able to say much but see the top response in: Solved: RITM Workflow Doesn't Trigger - ServiceNow Community

 

var grRITM = '??'; // The RITM GlideRecord

var w = new Workflow();
var wfSysId = w.getWorkflowFromName("workflowName");
var context = w.startFlow(wfSysId, grRITM, current.operation());

if (context != null){
	grRITM.context = context.sys_id;
	grRITM.update();
}

 

 

The script will instantiate a Workflow and associate it with the RITM. If you're using the CartAPI or whatever replaced this (as it might now be deprecated) then I would have expected the Workflow to have correctly associated with the RITM when it was generated.

 

The solution above was originally sourced from Request Generation Methods — ServiceNow Elite and there might be something helpful there if the above does not work.