- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2019 09:31 PM
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.
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2019 09:50 PM
hi subhashini,
Please remove the quotes of true in the if statement and try it.
if (g_scratchpad.grp == true)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2019 09:50 PM
hi subhashini,
Please remove the quotes of true in the if statement and try it.
if (g_scratchpad.grp == true)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2019 10:05 PM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2019 09:59 PM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2019 10:06 PM
You are right mate. Why would one use business rule for such a simple requirement?