How can I order a catalog item from Workflow

gmorales
Kilo Expert

Hi,

I'm trying to order a new catalog item from a workflow runScript action, the newly created item should be added to the current REQ, after it's creation the RITM is added to the current REQ wich is good, but when I open that RITM, there are no workflow and Variables.  

This what I've done so far...

function createRequestItem() {      

   

      var grReqItem = new GlideRecord("sc_req_item");

      grReqItem.initialize();      

      grReqItem.requested_for = current.variables.requested_for;      

      grReqItem.cat_item = '8a36d3850f6e924033859bd692050ef6';

      grReqItem.request = current.request;

      grReqItem.variables.v_current_carrier = current.variables.carrier_name;

      grReqItem.variables.v_current_number = current.variables.wireless_num;

      grReqItem.variables.v_request_type = "iPhone Activation only";

      var reqItemSysId = grReqItem.insert();

      gs.addInfoMessage('Request Item Created: ' + reqItemSysId);

      gs.addInfoMessage('Request Created: ' + grReqItem.number);    

}

createRequestItem();

Please if everyone have a better way to do this please let me know

1 ACCEPTED SOLUTION

I just reread that you're looking to add an item to an existing request, which is a little more difficult but doable. Here are some threads to follow:



How to add a new item to an existing request with catalog variables


add item to existing request


View solution in original post

3 REPLIES 3

Brad Tilton
ServiceNow Employee
ServiceNow Employee

The catalog has its own API for ordering that's a little different than just inserting a gliderecord.



Service catalog script API


I just reread that you're looking to add an item to an existing request, which is a little more difficult but doable. Here are some threads to follow:



How to add a new item to an existing request with catalog variables


add item to existing request


jbauguess
Tera Expert

You need to use this:



http://wiki.servicenow.com/index.php?title=Service_Catalog_Script_API#gsc.tab=0



It will help you create a requested item properly.