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();
ServiceNow script to remove inactive user from all the groups and roles
function removeTheGroupsOfInactiveUser() { var groupGR = new GlideRecord(‘sys_user_grmember’); groupGR.addQuery(‘user’, current.u_employee_name); groupGR.query(); while (groupGR.next()) { groupGR.deleteRecord(); } } function removeTheRolesOfInactiveUser() { var roleGR = new GlideRecord(‘sys_user_has_role’); roleGR.addQuery(‘user’, current.u_employee_name); roleGR.query(); while (roleGR.next()) { roleGR.deleteRecord(); } }
ServiceNow workflow run script to check if all the catalog tasks are closed for the current RITM
var tsk = new GlideRecord(‘sc_task’); tsk.addQuery(‘request_item’, current.sys_id); tsk.addActiveQuery(); tsk.query(); if(tsk.next()){ answer = false; } else{ answer = true; }