Script to add variables to catalog item created through run script in workflow

var reqvar = new GlideRecord(‘sc_item_option_mtom’); reqvar.addQuery(‘request_item’,current.sys_id); reqvar.query(); while (reqvar.next()) { var variablereference = new GlideRecord(‘sc_item_option’); if (variablereference.get(reqvar.sc_item_option)) { var add_task_var = new GlideRecord(‘sc_item_variables_task’); add_task_var.task = tsk_sys_id; add_task_var.variable = variablereference.item_option_new; add_task_var.insert(); } }

ServiceNow cart API to request catalog item through script

var cart = new Cart(); var item = cart.addItem(‘12345678123456781234567812345678’); // sys id of the Catalog item cart.setVariable(item, “employee”, current.u_employee_name); cart.setVariable(item, “employee_email”, current.u_employee_email); cart.setVariable(item, “employee_number”, current.u_employee_number); cart.setVariable(item, “termination_date”, current.u_termination_date); var rc = cart.placeOrder();