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:

(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')){
                g_processor.writeOutput('text/plain', 'Sys property updated');
                g_processor.writeOutput('text/plain', 'Sys property not located, please check');
            g_processor.writeOutput('text/plain', 'end day not entered, try again');
        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);


Popular posts from this blog

GlideRecord setValue

URL link in addInfoMessage