Code a processor with parameter

Example processor--code a processor which:
- pushes back if the user is not an admin
- if the user is an admin, takes a parameter passed in and uses it to set a system property
- processor url:
https://<yourinstance>.service-now.com/scheduled_sites_set_endday.do?endDayVal=7 




(function process(g_request, g_response, g_processor) {
   
    if (gs.hasRole("admin")){
        //--set the end day system property for the 'sites list of incidents' scheduled job to pick up
        var endDay=g_request.getParameter('endDayVal');
        g_processor.writeOutput('text/plain', 'endDay parameter: ' + endDay + '\r\n');
        if (!gs.nil(endDay)){
            var grSP= new GlideRecord('sys_properties');
            if (grSP.get('sys_id', 'ef1871be374113808ca1138943990e18')){
                grSP.value=endDay;
                grSP.update();
                g_processor.writeOutput('text/plain', 'Sys property updated');
               
            }else{
                g_processor.writeOutput('text/plain', 'Sys property not located, please check');
            }
        }else{
            g_processor.writeOutput('text/plain', 'end day not entered, try again');
        }
    }else{
        g_processor.writeOutput('text/plain', 'you are not an admin!');
        gs.log(gs.getUserID() + '--you are not an admin!','TP:incList:enddate');
    }
   
})(g_request, g_response, g_processor);

Comments

Popular posts from this blog

Running transform maps asynchronously

Post a command to the ECC queue for the mid server to initiate a powershell file copy

GlideRecord setValue