Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2025 04:31 AM
Hi @Adja Bineta
We have used it in one of our requirement, i am sharing you the function that we have used in our onBefore transform script: Check it once if it will helps you,
function raiseRequestUsingCartJS(userGR, source) {
var requestJson = {
"sysparm_id": "fa793f1n5k7654kbk47b4k91bfdb", //Catalog item
"sysparm_quantity": "1",
"variables": {
'u_requested_for': userGR.sys_id.toString(),
'u_employee_id': userGR.employee_number.toString(),
'u_email': userGR.email.toString(),
'u_requirement_business_justification': source.u_requirement.toString(),
'u_valid_till': source.u_valid_till.toString()
}
};
requestJson["variables"][pan] = true;
var cart = new sn_sc.CartJS(gs.generateGUID());
var cartDetails = cart.addToCart(requestJson);
var rc = cart.checkoutCart();
if (JSUtil.notNil(rc.request_id)) {
// Updating the RITM value in the source record
var grRITM = new GlideRecord('sc_req_item');
if (grRITM.get('request', rc.request_id)) {
source.u_ritm_sysid = grRITM.sys_id.toString();
}
}
}
Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning
Thanks & Regards
Deepak Sharma