Skip to main content

Posts

Kill a workflow wait block

this can be accomplished by a UI action (button) on the wf_executing table this can either be server side code: var url= /sys_trigger_list.do?sysparm_query=nameLIKE' + current.sys_id + '&sysparm_list_mode=grid'; action.setRedirectURL (url); or client side code: tick the client box in the onclick box, enter: go_to_trigger(); in the script box enter: function go_to_trigger(){     var grT=new GlideRecord('sys_trigger');      grT.addQuery('nameLIKE' + g_form.getUniqueValue() );      grT.query();      if (grT.next()){           var url=new GlideURL('/sys_trigger.do');           alert('redirecting to sys_trigger entry');             url.addParam('sys_id', grT.sys_id);            g_navigation.open(url.getURL(), '_blank');       } } note: you may need to enable popups in the browser for ...

UI Macro - external link in popup

<?xml version="1.0" encoding="utf-8" ?> <j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null"> <b style = "color: #DD3197" >Data Protection</b><br/> some text <a href='' onclick="event.preventDefault();gdprRef('${gs.getMessage('gdpr')}');">privacy notice</a> sets out how we process your data. <script> var myGDPRWindow; functiongdprRef(url){ if(g_form.modified){ g_form.modified=false; } var res=confirm('Do you wish to view the privacy notice?'); if (res){      myGDPRWindow=window.open(url, "s", "resizable=yes, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, copyhistory=no").blur();         //myGDPRWindow.focus(); g_form.modified=true; } }   </script> </j:jelly>

HasRolesExactly function

function gld_hasRoleExactly(role) { var au = new ArrayUtil(); var roles = gs.getSession().getRoles() + ''; var roleArray = roles.split(","); var isAuthorized = au.contains(roleArray, role); return isAuthorized; }//courtesy of https://joshneri.us/serverside-hasroleexactly-in-servicenow/

getNextObjNumberPadded(); auto-numbering issues...

getNextObjNumberPadded(); was not returning the latest number but one that already existed i've managed to fix this by going to /nav_to.do?uri=sys_number_counter.do?sys_id=<as per the table in question> see my community post on the topic https://community.servicenow.com/community?id=community_question&sys_id=206dba36dbf6ef80b1b102d5ca961986

ServiceNow retrieve all variables - record producer or RITM - from the generated ticket

ServiceNow retrieve all variables - record producer or RITM - from the generated ticket below example, i did this in a custom portal page widget. below is the server code function function getVariableValues(table, ticketNumber, optVariableName, optVariableName_db){   //--https://docs.servicenow.com/bundle/london-application-development/page/script/server-scripting/concept/c_ScriptableServiceCatalogVariables.html var gr= new GlideRecord(table);   gr.addQuery('number', ticketNumber);   gr.query();   var vars=[]; if (gr.next()) { for (var prop in gr.variables) {        if (gr.variables.hasOwnProperty(prop) ){        var variable =  gr.variables[prop].getDisplayValue();        var v = gr.variables[prop];           if(!gs.nil(v.getGlideObject().getQuestion().getLabel()) &&  !gs.nil(gr.variables[prop].getDisplayValue())) {   var label = v.get...