Skip to main content


Showing posts from January, 2019

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){, "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

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 /<as per the table in question> see my community post on the topic

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){   //-- var gr= new GlideRecord(table);   gr.addQuery('number', ticketNumber);   gr.query();   var vars=[]; if ( { 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.getGlideObject().getQuestion().getLabel();   var variableName=v.getGlideObject().getQuestion().getName();

Run a test load data from script calling processor

this is a modified version of the 'test load 20 records' ui action create this as a copy in the condition, add a condition to restrict it to the data source in question in this example a file import instead of having to redirect to the java processor, this can be done in script as follows: (instance calls itself via httprequest to access the processor, this can enable users without permissions but who can see the UI action to perform a test load on the data source with the file attached) ------------- current.update();  //--below is OOTB code, commented out but principles reused /*var redirectStr = ""; // the URI redirectStr += "import_source=data_source"; // this is a Data Source import redirectStr += "&sysparm_data_source=" + current.sys_id; // the sys_id of this redirectStr += "&sysparm_tablename=" + current.import_set_table_name; // always create the same test redirectStr += &