sn_sc.CartJS() create infinite RITM
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 02:50 AM
I would like the function to generate a single RITM for me, where am I going wrong? Thank you
(function executeRule(current, previous /*null when async*/ ) {
var user_sys = current.variables.user_transition.toString();
var userItem = new GlideRecord("sys_user");
userItem.addQuery('sys_id', user_sys);
userItem.query();
if (userItem.next()) {
var login = userItem.user_name;
var email = userItem.email;
var user = userItem.getUniqueValue();
var manager = userItem.manager.toString();
var uniOrg = userItem.department.toString();
var location = userItem.location.name.toString();
//var location_sys = userItem.location.toString();
var gr_ass = new GlideRecord('alm_hardware');
gr_ass.addQuery('assigned_to', user);
gr_ass.addQuery('install_status', '1'); // 1 - in use
gr_ass.addQuery('model_category', '81feb9c137101000deeabfc8bcbe5dc4'); // Computer
gr_ass.query();
if (gr_ass.next()) {
var pc = gr_ass.getUniqueValue();
var cart = new sn_sc.CartJS();
var request = {
'sysparm_id': 'abb7f60387427d506d7665370cbb35fa',
'sysparm_quantity': '1',
'variables': {
'parent': current.sys_id.toString(),
'business_unit': uniOrg,
'receiver': 'other',
'beneficiary': user,
'automatic': 'true',
'manager': manager,
'requested_for_location': location,
'login': login,
'email': email,
'asset': pc,
'required_activity': 'laborer_employee',
'srmc_id': '957b9ec8871a71906d7665370cbb357d'
}
};
var cartDetails = cart.orderNow(request);
//workflow.info(JSON.stringify(cartDetails));
gs.info('test br2'+ JSON.stringify(cartDetails));
}
}
})(current, previous);
0 REPLIES 0