Portada

martes, 14 de noviembre de 2023

Client Script de Servicenow que valida que el usuario tenga un rol para agregar casos P1

 Si no tiene el rol, no le permite agregar el caso, mostrando mensajes que llene ciertos campos antes.

Esto va a la tabla 'incident' y se ejecuta 'onSubmit'


function onSubmit() {

var name = g_user.userName;

    if (g_form.getValue('impact') == 1 && g_form.getValue('urgency') == 1 && !g_user.hasRoleExactly('major_inc_mgr')) {

        var ans = confirm("The Customer: is notified of all Priority-1 incidents. Confirm basic information is included before submitting this P1 incident.\n\nSelect Ok to submit, or cancel to return to the record. " + name);

        if (!ans) {

            g_form.addInfoMessage("incident is not submitted");

            g_form.addInfoMessage("If base information is unavailable, use the 'aditional coments' fiel to document why it is missing.");

            g_form.showFieldMsg('category', "Major Incident base field");

g_form.showFieldMsg('cmdb_ci', "Major incident base field");

g_form.showFieldMsg('assingment_group', "Major incident base field");

g_form.showFieldMsg('short_description', "Major incident base field");

        }

return(ans);

    }

}

No hay comentarios:

Publicar un comentario