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; }
Add show workflow UI Action in ServiceNow for Global and scoped applications
For Global Application use the following script onclik: showWorkflowContext() condition: !current.isNewRecord() && (new Workflow().hasWorkflow(current)) function showWorkflowContext() { var id = g_form.getUniqueValue().toString(); var url = new GlideURL(‘context_workflow.do’); url.addParam(‘sysparm_stack’, ‘no’); url.addParam(‘sysparm_table’, g_form.getTableName()); url.addParam(‘sysparm_document’, id); g_navigation.open(url.getURL(), “_blank”) } For Scoped Application use the following script onclik: showWorkflowContext() […]