caller Role client scripts

saran4
Kilo Guru

How to find the role of the caller in incident form from client side

1 ACCEPTED SOLUTION

JC Icaro1
Kilo Guru

From the client-side, you will have access to the g_user object. The methods which might help you are:

- hasRole

- hasRoleExactly

 

Here's some links which might help you.

https://servicenowguru.com/scripting/user-object-cheat-sheet/

https://developer.servicenow.com/dev.do#!/reference/api/quebec/client/c_GlideUserAPI?navFilter=glideuser

 

Otherwise, you will need to do a GlideAjax call or use g_scratchpad to make it available from the server-side to the client-side.

View solution in original post

11 REPLIES 11

Glad to help your here. If you have a follow up query then let me know else please mark my answer as correct and close this thread for others.

Regards,

Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Mahesh23
Mega Sage

Hi,

 

//onChange Client Script


if (newValue) {
        var ga = new GlideAjax('getRoles');
        ga.addParam('sysparm_name', 'getCallerRole');
        ga.addParam('sysparm_caller_id', newValue);
        ga.getXMLAnswer(getRoles);
    }

    function getRoles(response) {
        var answer = response;
		alert(answer);
    }

Script Include

var getRoles = Class.create();
getRoles.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    getCallerRole: function() {

        var getCaller = this.getParameter('sysparm_caller_id');
		
		return gs.getUser().getUserByID(getCaller).getRoles();;

    },

    type: 'getRoles'
});

 

find_real_file.png