The Zurich release has arrived! Interested in new features and functionalities? Click here for more

how to check current login user is in assignment group for incident table

subhashini6
Giga Contributor

hi

i write the business rule for display like this

var grpname = current.assignment_group.getDisplayValue();
gs.addInfoMessage(grpname);
g_scratchpad.grp = gs.getUser().isMemberOf(grpname);

 

and write the client script onload 

function onLoad() {

alert(g_scratchpad.grp);

alert("Hello1");
if (g_scratchpad.grp == 'true'){

alert("if con");
g_form.removeOption('state', '6'); //closed incomplete

g_form.removeOption('state', '7'); //closed skipped

}
else
{
alert("else con");
}

}

but ever time it is going to else block only.

when i am giving the alert(g_scratchpad.grp); the value is displaying true only.

 

where was the wrong in my code can u tell me any body.

1 ACCEPTED SOLUTION

dhananjay21
Giga Guru

hi subhashini,

 

Please remove the quotes of true in the if statement and try it.

if (g_scratchpad.grp == true)

View solution in original post

5 REPLIES 5

dhananjay21
Giga Guru

hi subhashini,

 

Please remove the quotes of true in the if statement and try it.

if (g_scratchpad.grp == true)

hi

thanks for your reply previously i tried with Boolean value but it not work. that why i changed to string.

any way once again thank you

Service_RNow
Mega Sage

Hi,

IF you want current user information in client script then please use g_user object

Getting a User Object - ServiceNow Wiki

Best practice is to use Glide Ajax for getting reference object information.

Replace g_form.getReference with GlideAjax?

getReference()     - best practice or not?

Client Script Examples — ServiceNow Elite

http://wiki.servicenow.com/index.php?title=GlideAjax#gsc.tab=0

Examples of asynchronous GlideAjax

Please mark reply as Helpful/Correct, if applicable. Thanks!

 

You are right mate. Why would one use business rule for such a simple requirement?