"new Cart()" does not seem to trigger workflow

Peteris
Mega Contributor

Hi!

Am having issues with creating request items via script using "new Cart();".

Request itself is being created, but the Workflow does not seem to start.

Issue seems to be apparent on London Patch 4 hotfix 2 version of SN.

Code I am using, as an example:

var cartId = GlideGuid.generate(null);
var cat_item_id = '04b7e94b4f7b4200086eeed18110c7fd';//Standard Laptop
var cart = new Cart(cartId);
var item = cart.addItem(cat_item_id);

cart.setVariable(item, "acrobat", true);
cart.setVariable(item, "photoshop", true);

var req = cart.placeOrder();

Result:

The same issue seems to be true for OOB instances under "glide-kingston-10-17-2017__patch12-11-28-2018" version.

Am I missing something?

1 ACCEPTED SOLUTION

Peteris
Mega Contributor

Update to my question:

After creating a HI ticket, turned out that one of the two instance nodes of the SN Instance needed to be restarted.

The technician was able to reproduce this issue only in one node of our SN instance and most likely something had gone wrong during last upgrade or plugin activation.

After restart issue was not there anymore.

 

Regards to the Kingston version and being able to reproduce this there.

OOB was working fine, the REQ items there got "stuck" because of "Service Catalog Request" workflow, where catalog items with prices > 1000 are having a separate approval.

Our instance had this workflow modified so that it does not use the price condition.

View solution in original post

4 REPLIES 4

Omkar Mone
Mega Sage

hi 

I think you need to user the Workflow() for triggering the workflow.

Check the below link :-

https://community.servicenow.com/community?id=community_question&sys_id=9a8c0fa5db9cdbc01dcaf3231f961957

Hi!

In the description field of the "Cart" script include there is nothing mentioned about triggering the WF separately and as everywhere else where I have looked for examples on how to create requests via script, nothing about WF triggering.

 

 

Rahul Kumar17
Tera Guru

hi

var w = new Workflow();


wfSysId = w.getWorkflowFromName("workflowName");


var context = w.startFlow(wfSysId, current, current.operation());


if (context != null){


current.context = context.sys_id;


current.update();


}

 

If my response helped please mark it correct and close the thread.

Thanks,
Rahul Kumar

Peteris
Mega Contributor

Update to my question:

After creating a HI ticket, turned out that one of the two instance nodes of the SN Instance needed to be restarted.

The technician was able to reproduce this issue only in one node of our SN instance and most likely something had gone wrong during last upgrade or plugin activation.

After restart issue was not there anymore.

 

Regards to the Kingston version and being able to reproduce this there.

OOB was working fine, the REQ items there got "stuck" because of "Service Catalog Request" workflow, where catalog items with prices > 1000 are having a separate approval.

Our instance had this workflow modified so that it does not use the price condition.