- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2019 10:11 PM
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?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2019 09:50 PM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2019 10:24 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2019 10:32 PM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2019 10:30 PM
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();
}
Thanks,
Rahul Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2019 09:50 PM
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.