- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2019 12:22 PM
Hello Community,
I have a request from a customer to be able to create multiple RITMs within an catalog item.
We cannot do this using the Order Guide due to the catalog item itself needing to be within an order guide but also requestable directly from the catalog.
We have multiple catalog items created for this, and they all use the same variables and need to display those variables within each RITM.
Example:
1. Submit Catalog Request.
2. Create RITM - Item One
2a. Create SCTASK - Item One
3. Create RITM - Item Two
3a. Create SCTASK - Item Two
4. Create RITM - Item Three
4a. Create SCTASK - Item Three
Much thanks,
Daniel Vargas
We have a script that is running this but it's not looking similar to base RITM being created by catalog item.
var gr = new GlideRecord('sc_req_item');
gr.initialize();
gr.request=current.request;
gr.request.requested_for=current.request.requested_for;
gr.cat_item='9da851db1ba40850705b86e8cd4bcb2a';
gr.cmdb_ci=current.cmdb_ci;
gr.short_description=current.short_description;
gr.description=current.description;
gr.insert();
var newRITM=gr.sys_id;
sc_item_option_mtom = new GlideRecord('sc_item_option_mtom');
sc_item_option_mtom.addQuery('request_item', current.sys_id);
sc_item_option_mtom.query();
while(sc_item_option_mtom.next()){
var sc_item_option = new GlideRecord('sc_item_option');
sc_item_option.addQuery('sys_id', sc_item_option_mtom.sc_item_option);
sc_item_option.query();
if(sc_item_option.next()){
var sc_item_option_insert = new GlideRecord('sc_item_option');
sc_item_option_insert.initialize();
sc_item_option_insert.item_option_new=sc_item_option.item_option_new;
sc_item_option_insert.value=sc_item_option.value;
sc_item_option_insert.insert();
var sc_item_option_mtom_insert = new GlideRecord('sc_item_option_mtom');
sc_item_option_mtom_insert.initialize();
sc_item_option_mtom_insert.request_item=newRITM;
sc_item_option_mtom_insert.sc_item_option=sc_item_option_insert.sys_id;
sc_item_option_mtom_insert.insert();
}
new Workflow().restartWorkflow(gr);
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2019 01:12 PM
Hello,
You didn't really tell us HOW it looks differently...but anyways...
If you aren't willing to use the order guide feature, then I would recommend creating the one base catalog item or using....one base catalog item to capture all the variables, etc.
Then...in the workflow, create a run script activity using the Cart API: https://docs.servicenow.com/bundle/newyork-application-development/page/script/server-scripting/refe...
That's how you'd create a new RITM and fill in everything so as you're coding it out, you would assign the variable in the new RITM to the current.variables.field_name version of the same.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2019 01:54 PM
I have a deployed something at my place, not sure if this can be of some help for you.
I have a catalog and based on one selection it has section appears and user filling that info to it.
Say : i select quantity as 1 than 1 section opens and based on this 1 ritm is created and if user select qty as 2 than 2 ritms and like wise.
For this i have created one dummy catalog which has same variables..
note: In each section information that is asked is same.... so same varaibles are on dummy catalog
A workflow is attached which does the trick of creating multiple ritm based on selection of Quantity
If you looking for something similar let me..i can share the code.
regards
rajesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2020 02:31 AM
Hello Rajesh,
I am doing somethink similar. Could you please share the code?
Thank you!
Manu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2020 03:52 AM
Hello,
sure
Plese PM me your email addree and requirement. I will send you step by step detials
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2020 05:57 AM
Hello Rajesh,
i'm also working on the similar requirement . could you please share the code
Thanks
Raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2020 03:51 AM
Here is what i have done.
My design was like i had 10 section and each sections had different variables and value selected may or may not be say.
Name of the variables were same but the backend name were different.
On this catalog a workflow was attached which used to push value to a backend catalog and this catalog had same variable(difference it had only one section)
Here is the code on the workflow which does the trick of creating multiple RITM.
Note : My sections used to show based on a field quantity.
Please change the code as per your requirement.
------
var numOfRequests = current.variables.quantity;
for (var i = 1; i <= numOfRequests; i++) {
var reqObj = getReqAllDetail(current, i);
var reqofficelocation = reqObj.OffLocation;
var reqbrand = reqObj.brand;
var reqhrdtype = reqObj.hrdtype;
var reqhardmov = reqObj.hardmov;
var reqassetname = reqObj.assetname;
var reqassetnamemn = reqObj.assetnamemn;
var reqsrnumber = reqObj.srnumber;
var reqmodelid = reqObj.modelid;
var reqmodelidmn = reqObj.modelidmn;
var reqassetnotfound = reqObj.assetnotfound;
var reqNamePr = reqObj.name;
var reqDeptPr = reqObj.deptName;
var reqExtPr = reqObj.extNumber;
var reqperipheral = reqObj.peripheraldevices;
var reqmonitor = reqObj.monitor;
var reqdocking = reqObj.docking;
var reqheadset = reqObj.headset;
var reqphone = reqObj.phone;
var reqwebcam = reqObj.webcam;
var reqwirelessmouse = reqObj.wirelessmouse;
var reqwiredmouse = reqObj.wiredmouse;
var reqwirelesskeyboard = reqObj.wirelesskeyboard;
var reqwiredkeyboard = reqObj.wiredkeyboard;
var reqmvfromBldg = reqObj.mvfromBldg;
var reqmvfromRm = reqObj.mvfromRm;
var reqmvFromFlr = reqObj.mvFromFlr;
var reqmvtoBldg = reqObj.mvtoBldg;
var reqmvtoRm = reqObj.mvtoRm;
var reqmvtoFlr = reqObj.mvtoFlr;
var reqaddcomments = reqObj.addcomments;
var reqstddsk = reqObj.stddsk;
var reqqty = reqObj.qty;
var reqdate = reqObj.date;
var reqremloc = reqObj.remote;
placeOrder(current, reqofficelocation, reqbrand, reqhrdtype, reqhardmov, reqassetname, reqassetnamemn, reqsrnumber, reqmodelid, reqmodelidmn, reqassetnotfound, reqNamePr, reqDeptPr, reqExtPr, reqperipheral, reqmonitor, reqdocking, reqheadset, reqphone, reqwebcam, reqwirelessmouse, reqwiredmouse, reqwirelesskeyboard, reqwiredkeyboard, reqmvfromBldg, reqmvfromRm, reqmvFromFlr, reqmvtoBldg, reqmvtoRm, reqmvtoFlr, reqaddcomments, reqstddsk, reqqty, reqdate, reqremloc);
}
//delete current request item
current.deleteRecord();
function placeOrder(current, reqofficelocation, reqbrand, reqhrdtype, reqhardmov, reqassetname, reqassetnamemn, reqsrnumber, reqmodelid, reqmodelidmn, reqassetnotfound, reqNamePr, reqDeptPr, reqExtPr, reqperipheral, reqmonitor, reqdocking, reqheadset, reqphone, reqwebcam, reqwirelessmouse, reqwiredmouse, reqwirelesskeyboard, reqwiredkeyboard, reqmvfromBldg, reqmvfromRm, reqmvFromFlr, reqmvtoBldg, reqmvtoRm, reqmvtoFlr, reqaddcomments, reqstddsk, reqqty, reqdate, reqremloc) {
var catItem = 'b75ff3e9dbad3bc0d3767ffb8c96195b';
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem(catItem);
cart.setVariable(item, 'requested_by', gs.getUserID());
cart.setVariable(item, 'requesters_manager', current.variables.requesters_manager);
cart.setVariable(item, 'requested_for', current.variables.requested_for);
cart.setVariable(item, 'bestmethod_contact', current.variables.bestmethod_contact);
cart.setVariable(item, 'office_location', reqofficelocation);
cart.setVariable(item, 'brand', reqbrand);
cart.setVariable(item, 'hardware_type', reqhrdtype);
cart.setVariable(item, 'moved_picked_up', reqhardmov);
cart.setVariable(item, 'asset_name', reqassetname);
cart.setVariable(item, 'asset_name_manual', reqassetnamemn);
cart.setVariable(item, 'serial_number', reqsrnumber);
cart.setVariable(item, 'asset_modelId', reqmodelid);
cart.setVariable(item, 'asset_modelId_manual', reqmodelidmn);
cart.setVariable(item, 'assetname_notfound', reqassetnotfound);
cart.setVariable(item, 'name_person_moving', reqNamePr);
cart.setVariable(item, 'dept_name', reqDeptPr);
cart.setVariable(item, 'ext_number', reqExtPr);
cart.setVariable(item, 'peripheral_devices', reqperipheral);
cart.setVariable(item, 'monitor', reqmonitor);
cart.setVariable(item, 'docking_system', reqdocking);
cart.setVariable(item, 'headset', reqheadset);
cart.setVariable(item, 'phone', reqphone);
cart.setVariable(item, 'webcam', reqwebcam);
cart.setVariable(item, 'wirelessmouse', reqwirelessmouse);
cart.setVariable(item, 'wiredmouse', reqwiredmouse);
cart.setVariable(item, 'wirelesskeyboard', reqwirelesskeyboard);
cart.setVariable(item, 'wiredkeyboard', reqwiredkeyboard);
cart.setVariable(item, 'moving_from_provide_building', reqmvfromBldg);
cart.setVariable(item, 'moving_from_provide_room', reqmvfromRm);
cart.setVariable(item, 'moving_from_provide_floor', reqmvFromFlr);
cart.setVariable(item, 'moving_to_provide_building', reqmvtoBldg);
cart.setVariable(item, 'moving_to_provide_room', reqmvtoRm);
cart.setVariable(item, 'moving_to_provide_floor', reqmvtoFlr);
cart.setVariable(item, 'details_request', reqaddcomments);
cart.setVariable(item, 'standup_desk', reqstddsk);
cart.setVariable(item, 'quantity', reqqty);
cart.setVariable(item, 'move_date', reqdate);
cart.setVariable(item, 'moving_to_remote', reqremloc);
var rc = cart.placeOrder();
var reqObj = current.request.getRefRecord();
reqObj.u_requested_by = gs.getUserID();
reqObj.update();
//Update all requests created with the first request
changeRequestId(rc.sys_id);
}
function changeRequestId(reqId) {
var scItem = new GlideRecord("sc_req_item");
scItem.addQuery("request", reqId);
scItem.query();
if (scItem.next()) {
scItem.request = current.request;
scItem.update();
}
// Delete empty request created
var scReq = new GlideRecord("sc_request");
scReq.addQuery("sys_id", reqId);
scReq.query();
if (scReq.next()) {
scReq.deleteRecord();
}
}
//1
function getReqAllDetail(current, reqNum) {
var reqObj = new JSON();
switch (reqNum) {
case 1:
reqObj.OffLocation = current.variables.additional_office_location_1;
reqObj.brand = current.variables.brand;
reqObj.hrdtype = current.variables.hardware_type1;
reqObj.hardmov = current.variables.moved_picked_up_1;
reqObj.assetname = current.variables.asset_name1;
reqObj.srnumber = current.variables.serial_number1;
reqObj.modelid = current.variables.asset_modelID1;
reqObj.assetnotfound = current.variables.assetname_notfound1;
reqObj.name = current.variables.name_person_moving_1;
reqObj.deptName = current.variables.dept_name_1;
reqObj.extNumber = current.variables.ext_number_1;
reqObj.assetnamemn = current.variables.asset_name_manual1;
reqObj.modelidmn = current.variables.modelid_manual1;
reqObj.peripheraldevices = current.variables.peripheral_devices1;
reqObj.monitor = current.variables.monitor1;
reqObj.docking = current.variables.docking_system_1;
reqObj.headset = current.variables.headset1;
reqObj.phone = current.variables.phone1;
reqObj.webcam = current.variables.webcam_1;
reqObj.wirelessmouse = current.variables.wirelessmouse_1;
reqObj.wiredmouse = current.variables.wiredmouse_1;
reqObj.wirelesskeyboard = current.variables.wirelesskeyboard_1;
reqObj.wiredkeyboard = current.variables.wiredkeyboard_1;
reqObj.mvfromBldg = current.variables.moving_from_provide_building_1_1;
reqObj.mvfromRm = current.variables.moving_from_provide_room_1;
reqObj.mvFromFlr = current.variables.moving_from_provide_floor_1_1;
reqObj.mvtoBldg = current.variables.moving_to_provide_building_1_1;
reqObj.mvtoRm = current.variables.moving_to_provide_room_1;
reqObj.mvtoFlr = current.variables.moving_to_provide_floor_1_1;
reqObj.addcomments = current.variables.details_request_1;
reqObj.stddsk = current.variables.standup_desk1;
reqObj.qty = current.variables.quantity;
reqObj.date = current.variables.move_date;
reqObj.remote = current.variables.moving_to_remote_1;
break;
case 2:
reqObj.OffLocation = current.variables.additional_office_location_1;
reqObj.brand = current.variables.brand;
reqObj.hrdtype = current.variables.hardware_type2;
reqObj.hardmov = current.variables.moved_picked_up_2;
reqObj.assetname = current.variables.asset_name2;
reqObj.srnumber = current.variables.serial_number2;
reqObj.modelid = current.variables.asset_modelID2;
reqObj.assetnotfound = current.variables.assetname_notfound2;
reqObj.name = current.variables.name_person_moving_2;
reqObj.deptName = current.variables.dept_name_2;
reqObj.extNumber = current.variables.ext_number_2;
reqObj.assetnamemn = current.variables.asset_name_manual2;
reqObj.modelidmn = current.variables.modelid_manual2;
reqObj.peripheraldevices = current.variables.peripheral_devices2;
reqObj.monitor = current.variables.monitor2;
reqObj.docking = current.variables.docking_system_2;
reqObj.headset = current.variables.headset2;
reqObj.phone = current.variables.phone2;
reqObj.webcam = current.variables.webcam_2;
reqObj.wirelessmouse = current.variables.wirelessmouse_2;
reqObj.wiredmouse = current.variables.wiredmouse_2;
reqObj.wirelesskeyboard = current.variables.wirelesskeyboard_2;
reqObj.wiredkeyboard = current.variables.wiredkeyboard_2;
reqObj.mvfromBldg = current.variables.moving_from_provide_building_2_1;
reqObj.mvfromRm = current.variables.moving_from_provide_room_2;
reqObj.mvFromFlr = current.variables.moving_from_provide_floor_2_1;
reqObj.mvtoBldg = current.variables.moving_to_provide_building_2_1;
reqObj.mvtoRm = current.variables.moving_to_provide_room_2;
reqObj.mvtoFlr = current.variables.moving_to_provide_floor_2_1;
reqObj.addcomments = current.variables.details_request_2;
reqObj.stddsk = current.variables.standup_desk2;
reqObj.qty = current.variables.quantity;
reqObj.date = current.variables.move_date;
reqObj.remote = current.variables.moving_to_remote_2;
break;
case 3:
reqObj.OffLocation = current.variables.additional_office_location_1;
reqObj.brand = current.variables.brand;
reqObj.hrdtype = current.variables.hardware_type3;
reqObj.hardmov = current.variables.moved_picked_up_3;
reqObj.assetname = current.variables.asset_name3;
reqObj.srnumber = current.variables.serial_number3;
reqObj.modelid = current.variables.asset_modelID3;
reqObj.assetnotfound = current.variables.assetname_notfound3;
reqObj.name = current.variables.name_person_moving_3;
reqObj.deptName = current.variables.dept_name_3;
reqObj.extNumber = current.variables.ext_number_3;
reqObj.assetnamemn = current.variables.asset_name_manual3;
reqObj.modelidmn = current.variables.modelid_manual3;
reqObj.peripheraldevices = current.variables.peripheral_devices3;
reqObj.monitor = current.variables.monitor3;
reqObj.docking = current.variables.docking_system_3;
reqObj.headset = current.variables.headset3;
reqObj.phone = current.variables.phone3;
reqObj.webcam = current.variables.webcam_3;
reqObj.wirelessmouse = current.variables.wirelessmouse_3;
reqObj.wiredmouse = current.variables.wiredmouse_3;
reqObj.wirelesskeyboard = current.variables.wirelesskeyboard_3;
reqObj.wiredkeyboard = current.variables.wiredkeyboard_3;
reqObj.mvfromBldg = current.variables.moving_from_provide_building_3_1;
reqObj.mvfromRm = current.variables.moving_from_provide_room_3;
reqObj.mvFromFlr = current.variables.moving_from_provide_floor_3_1;
reqObj.mvtoBldg = current.variables.moving_to_provide_building_3_1;
reqObj.mvtoRm = current.variables.moving_to_provide_room_3;
reqObj.mvtoFlr = current.variables.moving_to_provide_floor_3_1;
reqObj.addcomments = current.variables.details_request_3;
reqObj.stddsk = current.variables.standup_desk3;
reqObj.qty = current.variables.quantity;
reqObj.date = current.variables.move_date;
reqObj.remote = current.variables.moving_to_remote_3;
break;
case 4:
reqObj.OffLocation = current.variables.additional_office_location_1;
reqObj.brand = current.variables.brand;
reqObj.hrdtype = current.variables.hardware_type4;
reqObj.hardmov = current.variables.moved_picked_up_4;
reqObj.assetname = current.variables.asset_name4;
reqObj.srnumber = current.variables.serial_number4;
reqObj.modelid = current.variables.asset_modelID4;
reqObj.assetnotfound = current.variables.assetname_notfound4;
reqObj.name = current.variables.name_person_moving_4;
reqObj.deptName = current.variables.dept_name_4;
reqObj.extNumber = current.variables.ext_number_4;
reqObj.assetnamemn = current.variables.asset_name_manual4;
reqObj.modelidmn = current.variables.modelid_manual4;
reqObj.peripheraldevices = current.variables.peripheral_devices4;
reqObj.monitor = current.variables.monitor4;
reqObj.docking = current.variables.docking_system_4;
reqObj.headset = current.variables.headset4;
reqObj.phone = current.variables.phone4;
reqObj.webcam = current.variables.webcam_4;
reqObj.wirelessmouse = current.variables.wirelessmouse_4;
reqObj.wiredmouse = current.variables.wiredmouse_4;
reqObj.wirelesskeyboard = current.variables.wirelesskeyboard_4;
reqObj.wiredkeyboard = current.variables.wiredkeyboard_4;
reqObj.mvfromBldg = current.variables.moving_from_provide_building_4_1;
reqObj.mvfromRm = current.variables.moving_from_provide_room_4;
reqObj.mvFromFlr = current.variables.moving_from_provide_floor_4_1;
reqObj.mvtoBldg = current.variables.moving_to_provide_building_4_1;
reqObj.mvtoRm = current.variables.moving_to_provide_room_4;
reqObj.mvtoFlr = current.variables.moving_to_provide_floor_4_1;
reqObj.addcomments = current.variables.details_request_4;
reqObj.stddsk = current.variables.standup_desk4;
reqObj.qty = current.variables.quantity;
reqObj.date = current.variables.move_date;
reqObj.remote = current.variables.moving_to_remote_4;
break;
case 5:
reqObj.OffLocation = current.variables.additional_office_location_1;
reqObj.brand = current.variables.brand;
reqObj.hrdtype = current.variables.hardware_type5;
reqObj.hardmov = current.variables.moved_picked_up_5;
reqObj.assetname = current.variables.asset_name5;
reqObj.srnumber = current.variables.serial_number5;
reqObj.modelid = current.variables.asset_modelID5;
reqObj.assetnotfound = current.variables.assetname_notfound5;
reqObj.name = current.variables.name_person_moving_5;
reqObj.deptName = current.variables.dept_name_5;
reqObj.extNumber = current.variables.ext_number_5;
reqObj.assetnamemn = current.variables.asset_name_manual5;
reqObj.modelidmn = current.variables.modelid_manual5;
reqObj.peripheraldevices = current.variables.peripheral_devices5;
reqObj.monitor = current.variables.monitor5;
reqObj.docking = current.variables.docking_system_5;
reqObj.headset = current.variables.headset5;
reqObj.phone = current.variables.phone5;
reqObj.webcam = current.variables.webcam_5;
reqObj.wirelessmouse = current.variables.wirelessmouse_5;
reqObj.wiredmouse = current.variables.wiredmouse_5;
reqObj.wirelesskeyboard = current.variables.wirelesskeyboard_5;
reqObj.wiredkeyboard = current.variables.wiredkeyboard_5;
reqObj.mvfromBldg = current.variables.moving_from_provide_building_5_1;
reqObj.mvfromRm = current.variables.moving_from_provide_room_5;
reqObj.mvFromFlr = current.variables.moving_from_provide_floor_5_1;
reqObj.mvtoBldg = current.variables.moving_to_provide_building_5_1;
reqObj.mvtoRm = current.variables.moving_to_provide_room_5;
reqObj.mvtoFlr = current.variables.moving_to_provide_floor_5_1;
reqObj.addcomments = current.variables.details_request_5;
reqObj.stddsk = current.variables.standup_desk5;
reqObj.qty = current.variables.quantity;
reqObj.date = current.variables.move_date;
reqObj.remote = current.variables.moving_to_remote_5;
break;
case 6:
reqObj.OffLocation = current.variables.additional_office_location_1;
reqObj.brand = current.variables.brand;
reqObj.hrdtype = current.variables.hardware_type6;
reqObj.hardmov = current.variables.moved_picked_up_6;
reqObj.assetname = current.variables.asset_name6;
reqObj.srnumber = current.variables.serial_number6;
reqObj.modelid = current.variables.asset_modelID6;
reqObj.assetnotfound = current.variables.assetname_notfound6;
reqObj.name = current.variables.name_person_moving_6;
reqObj.deptName = current.variables.dept_name_6;
reqObj.extNumber = current.variables.ext_number_6;
reqObj.assetnamemn = current.variables.asset_name_manual6;
reqObj.modelidmn = current.variables.modelid_manual6;
reqObj.peripheraldevices = current.variables.peripheral_devices6;
reqObj.monitor = current.variables.monitor6;
reqObj.docking = current.variables.docking_system_6;
reqObj.headset = current.variables.headset6;
reqObj.phone = current.variables.phone6;
reqObj.webcam = current.variables.webcam_6;
reqObj.wirelessmouse = current.variables.wirelessmouse_6;
reqObj.wiredmouse = current.variables.wiredmouse_6;
reqObj.wirelesskeyboard = current.variables.wirelesskeyboard_6;
reqObj.wiredkeyboard = current.variables.wiredkeyboard_6;
reqObj.mvfromBldg = current.variables.moving_from_provide_building_6_1;
reqObj.mvfromRm = current.variables.moving_from_provide_room_6;
reqObj.mvFromFlr = current.variables.moving_from_provide_floor_6_1;
reqObj.mvtoBldg = current.variables.moving_to_provide_building_6_1;
reqObj.mvtoRm = current.variables.moving_to_provide_room_6;
reqObj.mvtoFlr = current.variables.moving_to_provide_floor_6_1;
reqObj.addcomments = current.variables.details_request_6;
reqObj.stddsk = current.variables.standup_desk6;
reqObj.qty = current.variables.quantity;
reqObj.date = current.variables.move_date;
reqObj.remote = current.variables.moving_to_remote_6;
break;
case 7:
reqObj.OffLocation = current.variables.additional_office_location_1;
reqObj.brand = current.variables.brand;
reqObj.hrdtype = current.variables.hardware_type7;
reqObj.hardmov = current.variables.moved_picked_up_7;
reqObj.assetname = current.variables.asset_name7;
reqObj.srnumber = current.variables.serial_number7;
reqObj.modelid = current.variables.asset_modelID7;
reqObj.assetnotfound = current.variables.assetname_notfound7;
reqObj.name = current.variables.name_person_moving_7;
reqObj.deptName = current.variables.dept_name_7;
reqObj.extNumber = current.variables.ext_number_7;
reqObj.assetnamemn = current.variables.asset_name_manual7;
reqObj.modelidmn = current.variables.modelid_manual7;
reqObj.peripheraldevices = current.variables.peripheral_devices7;
reqObj.monitor = current.variables.monitor7;
reqObj.docking = current.variables.docking_system_7;
reqObj.headset = current.variables.headset7;
reqObj.phone = current.variables.phone7;
reqObj.webcam = current.variables.webcam_7;
reqObj.wirelessmouse = current.variables.wirelessmouse_7;
reqObj.wiredmouse = current.variables.wiredmouse_7;
reqObj.wirelesskeyboard = current.variables.wirelesskeyboard_7;
reqObj.wiredkeyboard = current.variables.wiredkeyboard_7;
reqObj.mvfromBldg = current.variables.moving_from_provide_building_7_1;
reqObj.mvfromRm = current.variables.moving_from_provide_room_7_1;
reqObj.mvFromFlr = current.variables.moving_from_provide_floor_7_1;
reqObj.mvtoBldg = current.variables.moving_to_provide_building_7;
reqObj.mvtoRm = current.variables.moving_to_provide_room_7;
reqObj.mvtoFlr = current.variables.moving_to_provide_floor_7_1;
reqObj.addcomments = current.variables.details_request_7;
reqObj.stddsk = current.variables.standup_desk7;
reqObj.qty = current.variables.quantity;
reqObj.date = current.variables.move_date;
reqObj.remote = current.variables.moving_to_remote_7;
break;
case 8:
reqObj.OffLocation = current.variables.additional_office_location_1;
reqObj.brand = current.variables.brand;
reqObj.hrdtype = current.variables.hardware_type8;
reqObj.hardmov = current.variables.moved_picked_up_8;
reqObj.assetname = current.variables.asset_name8;
reqObj.srnumber = current.variables.serial_number8;
reqObj.modelid = current.variables.asset_modelID8;
reqObj.assetnotfound = current.variables.assetname_notfound8;
reqObj.name = current.variables.name_person_moving_8;
reqObj.deptName = current.variables.dept_name_8;
reqObj.extNumber = current.variables.ext_number_8;
reqObj.assetnamemn = current.variables.asset_name_manual8;
reqObj.modelidmn = current.variables.modelid_manual8;
reqObj.peripheraldevices = current.variables.peripheral_devices8;
reqObj.monitor = current.variables.monitor8;
reqObj.docking = current.variables.docking_system_8;
reqObj.headset = current.variables.headset8;
reqObj.phone = current.variables.phone8;
reqObj.webcam = current.variables.webcam_8;
reqObj.wirelessmouse = current.variables.wirelessmouse_8;
reqObj.wiredmouse = current.variables.wiredmouse_8;
reqObj.wirelesskeyboard = current.variables.wirelesskeyboard_8;
reqObj.wiredkeyboard = current.variables.wiredkeyboard_8;
reqObj.mvfromBldg = current.variables.moving_from_provide_building_8_1;
reqObj.mvfromRm = current.variables.moving_from_provide_room_8;
reqObj.mvFromFlr = current.variables.moving_from_provide_floor_8_1;
reqObj.mvtoBldg = current.variables.moving_to_provide_building_8_1;
reqObj.mvtoRm = current.variables.moving_to_provide_room_8;
reqObj.mvtoFlr = current.variables.moving_to_provide_floor_8_1;
reqObj.addcomments = current.variables.details_request_8;
reqObj.stddsk = current.variables.standup_desk8;
reqObj.qty = current.variables.quantity;
reqObj.date = current.variables.move_date;
reqObj.remote = current.variables.moving_to_remote_8;
break;
case 9:
reqObj.OffLocation = current.variables.additional_office_location_1;
reqObj.brand = current.variables.brand;
reqObj.hrdtype = current.variables.hardware_type9;
reqObj.hardmov = current.variables.moved_picked_up_9;
reqObj.assetname = current.variables.asset_name9;
reqObj.srnumber = current.variables.serial_number9;
reqObj.modelid = current.variables.asset_modelID9;
reqObj.assetnotfound = current.variables.assetname_notfound9;
reqObj.name = current.variables.name_person_moving_9;
reqObj.deptName = current.variables.dept_name_9;
reqObj.extNumber = current.variables.ext_number_9;
reqObj.assetnamemn = current.variables.asset_name_manual9;
reqObj.modelidmn = current.variables.modelid_manual9;
reqObj.peripheraldevices = current.variables.peripheral_devices9;
reqObj.monitor = current.variables.monitor9;
reqObj.docking = current.variables.docking_system_9;
reqObj.headset = current.variables.headset9;
reqObj.phone = current.variables.phone9;
reqObj.webcam = current.variables.webcam_9;
reqObj.wirelessmouse = current.variables.wirelessmouse_9;
reqObj.wiredmouse = current.variables.wiredmouse_9;
reqObj.wirelesskeyboard = current.variables.wirelesskeyboard_9;
reqObj.wiredkeyboard = current.variables.wiredkeyboard_9;
reqObj.mvfromBldg = current.variables.moving_from_provide_building_9_1;
reqObj.mvfromRm = current.variables.moving_from_provide_room_9;
reqObj.mvFromFlr = current.variables.moving_from_provide_floor_9_1;
reqObj.mvtoBldg = current.variables.moving_to_provide_building_9_1;
reqObj.mvtoRm = current.variables.moving_to_provide_room_9;
reqObj.mvtoFlr = current.variables.moving_to_provide_floor_9_1;
reqObj.addcomments = current.variables.details_request_9;
reqObj.stddsk = current.variables.standup_desk9;
reqObj.qty = current.variables.quantity;
reqObj.date = current.variables.move_date;
reqObj.remote = current.variables.moving_to_remote_9;
break;
case 10:
reqObj.OffLocation = current.variables.additional_office_location_1;
reqObj.brand = current.variables.brand;
reqObj.hrdtype = current.variables.hardware_type10;
reqObj.hardmov = current.variables.moved_picked_up_10;
reqObj.assetname = current.variables.asset_name10;
reqObj.srnumber = current.variables.serial_number10;
reqObj.modelid = current.variables.asset_modelID10;
reqObj.assetnotfound = current.variables.assetname_notfound10;
reqObj.name = current.variables.name_person_moving_10;
reqObj.deptName = current.variables.dept_name_10;
reqObj.extNumber = current.variables.ext_number_10;
reqObj.assetnamemn = current.variables.asset_name_manual10;
reqObj.modelidmn = current.variables.modelid_manual10;
reqObj.peripheraldevices = current.variables.peripheral_devices10;
reqObj.monitor = current.variables.monitor10;
reqObj.docking = current.variables.docking_system_10;
reqObj.headset = current.variables.headset10;
reqObj.phone = current.variables.phone10;
reqObj.webcam = current.variables.webcam_10;
reqObj.wirelessmouse = current.variables.wirelessmouse_10;
reqObj.wiredmouse = current.variables.wiredmouse_10;
reqObj.wirelesskeyboard = current.variables.wirelesskeyboard_10;
reqObj.wiredkeyboard = current.variables.wiredkeyboard_10;
reqObj.mvfromBldg = current.variables.moving_from_provide_building_10_1;
reqObj.mvfromRm = current.variables.moving_from_provide_room_10;
reqObj.mvFromFlr = current.variables.moving_from_provide_floor_10_1;
reqObj.mvtoBldg = current.variables.moving_to_provide_building_10_1;
reqObj.mvtoRm = current.variables.moving_to_provide_room_10;
reqObj.mvtoFlr = current.variables.moving_to_provide_floor_10_1;
reqObj.addcomments = current.variables.details_request_10;
reqObj.stddsk = current.variables.standup_desk10;
reqObj.qty = current.variables.quantity;
reqObj.date = current.variables.move_date;
reqObj.remote = current.variables.moving_to_remote_10;
break;
}
return reqObj;
}
=======
same logic was used for for MVRS.
Same backend table.
but here there was no case/switch statement that was required.
var rowCount = current.variables.<mvrs name>;
//gs.addInfoMessage('value of row count is' + rowCount);
for (var i = 0; i < rowCount; i++) {
var row = current.variables.<name of MVRS>.getRow(i);
var pname = row.preferred_name_multi;
var aname = row.name_multi;
var mirror = row.mirror_id_multi;
var tele = row.telephone_multi;
var ext = row.extension_mirrorid;
placeOrder(current, aname, mirror, tele, ext);
}
current.deleteRecord();
function placeOrder(current, aname, mirror, tele, ext) {
var catItem = 'f4025599dbe85010f1ac751c8c961964'; /// sysid of backend catalog
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem(catItem);
cart.setVariable(item, 'requested_by', gs.getUserID());
cart.setVariable(item, 'requesters_manager', current.variables.requesters_manager);
cart.setVariable(item, 'requested_for', current.variables.requested_for);
cart.setVariable(item, 'bestmethod_contact', current.variables.bestmethod_contact);
cart.setVariable(item, 'mirror', mirror);
cart.setVariable(item, 'date', current.variables.required_by);
cart.setVariable(item, 'comment', current.variables.comments);
cart.setVariable(item, 'name', aname);
cart.setVariable(item, 'telephone', tele);
cart.setVariable(item, 'preferred_name', pname);
cart.setVariable(item, 'extension_mirrorid', ext);
var rc = cart.placeOrder();
var reqObj = current.request.getRefRecord();
reqObj.u_requested_by = gs.getUserID();
reqObj.update();
//Update all requests created with the first request
changeRequestId(rc.sys_id);
}
function changeRequestId(reqId) {
var scItem = new GlideRecord("sc_req_item");
scItem.addQuery("request", reqId);
scItem.query();
if (scItem.next()) {
scItem.request = current.request;
scItem.update();
}
// Delete empty request created
var scReq = new GlideRecord("sc_request");
scReq.addQuery("sys_id", reqId);
scReq.query();
if (scReq.next()) {
scReq.deleteRecord();
}
}