how to write the transform map or scripted rest resource to get the ritm(number)created
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2022 06:47 AM
I have a requirement to create ritm using the transform map and set the assignment group to catalog task level
I have tried 2 approaches firstly with the transform map and secondly with the scripted rest api(in both approaches ritmnumber not getting in response object) i need to some validations with ritm number to set the "assignment group"at the catalog task level.
Please suggest if anybody come across the requirement.
1.transform scripts with the ritm as target table
var src_business_service=source.u_src_business_service;
var src_short_description_en=source.u_src_short_description_en;
var src_best_contact_number=source.u_src_best_contact_number;
var src_site_req_for=source.u_src_site_req_for;
var src_subcategory=source.u_src_subcategory;
gs.log('src_business_service'+src_business_service);
gs.log('source.src_short_description_en'+src_short_description_en);
// Add your code here
var cart = new Cart();
var item = cart.addItem("892d0f0b4f0a76008c13e0ed0210c724");
cart.setVariable(item, 'src_business_service',src_business_service);
cart.setVariable(item, 'src_short_description_en', src_short_description_en);
cart.setVariable(item, 'src_best_contact_number', src_best_contact_number);
cart.setVariable(item, 'src_site_req_for', src_site_req_for);
cart.setVariable(item, 'src_subcategory', src_subcategory);
var cartGR = cart.getCart();
cartGR.update();
var newSerReq = cart.placeOrder();
ignore = true;
})(source, target, map, log, action==="insert");
2.scripted rest api code
// implement resource here
var cart = new Cart();
var item = cart.addItem("892d0f0b4f0a76008c13e0ed0210c724");
cart.setVariable(item, 'src_business_service','00016d79dbf42b0428fa1bfa4b961970');
cart.setVariable(item, 'src_short_description_en', 'testing');
cart.setVariable(item, 'src_best_contact_number', '123');
cart.setVariable(item, 'src_site_req_for', 'd5cf23e61bf1d850656e437ead4bcbbf');
cart.setVariable(item, 'src_subcategory', 'Data collection');
cart.setVariable(item, 'src_business_line', '1e1625aadba9cf4052fdd7795e9619f1');
cart.setVariable(item, 'src_description_set_en', 'testing on oct18th');
var cartGR = cart.getCart();
cartGR.update();
var newSerReq = cart.placeOrder();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2022 07:10 AM
Hi
Using Scripted REST api, you can always send the response. After the last line
var newSerReq = cart.placeOrder();
GlideRecord sc_req_item table with condition as
gr.addQuery('request' ,newSerReq);
You'll get all the requested items. Simply return this requested item number or sys_id.
Thanks
Madhav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2022 10:35 AM
Hi thanks for the quick response.
i have added below lines of code but no luck
var gr5 = new GlideRecord('sc_req_item');
gr5.addQuery('request',newSerReq.sys_id);
gr5.query();
if(gr5.next()) {
var ritmnumber=gr5.number;
}
return ritmnumber;