- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2021 01:30 AM
i know that on business Rule we use code if (gs.getUser().isMemberOf('Database Application Support')) {}
However do not know how to chekc the same thorugh on load client script.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2021 01:36 AM
Hi,
Create a Business rules as below:
Display Query Business rules
(function executeRule(current, previous /*null when async*/ ) {
g_scratchpad.grp = gs.getUser().isMemberOf('sys_id of the group');
g_scratchpad.usrid = gs.getUserID(); // gets current logged in user
})(current, previous);
Then Create Client script
if((g_scratchpad.grp.toString() == 'true'))
{
//script you want to execute
}
Thank You,
Arkesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2021 01:36 AM
Hi,
Create a Business rules as below:
Display Query Business rules
(function executeRule(current, previous /*null when async*/ ) {
g_scratchpad.grp = gs.getUser().isMemberOf('sys_id of the group');
g_scratchpad.usrid = gs.getUserID(); // gets current logged in user
})(current, previous);
Then Create Client script
if((g_scratchpad.grp.toString() == 'true'))
{
//script you want to execute
}
Thank You,
Arkesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2021 03:38 AM
If My Answer helps. Make my answer as Correct answer / Helpful
Thank You,
Arkesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2021 01:58 AM
Hi Vikas ,
I have done this but by using onChange Client script and business rule.
One Important point is here , first ypu add current logged in user in your group and then do testing .
PFB code :-
Script Include :-
var MemberofAssignmentGroupCS = Class.create();
MemberofAssignmentGroupCS.prototype = Object.extendsObject(AbstractAjaxProcessor, {
assing: function() {
var g = this.getParameter('sysparm_group');
gs.addErrorMessage(g);
if (gs.getUser().isMemberOf(g)) {
return true;
} else {
return false;
}
},
type: 'MemberofAssignmentGroupCS'
});
Client Script(Assignment group)
unction onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('MemberofAssignmentGroupCS');
ga.addParam('sysparm_name', 'assing');
ga.addParam('sysparm_group', g_form.getValue('assignment_group'));
ga.getXML(memberOfAssignee);
function memberOfAssignee(response) {
var ans = response.responseXML.documentElement.getAttribute('answer');
alert(ans);
if (ans == 'true') {
g_form.setReadOnly('short_description', true);
} else {
g_form.setReadOnly('short_description', false);
}
}
}
Pls mark me correct or helpful
Thanks ,
Akanksha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2021 03:42 AM
Hi,
There is no need of Script Include / Ajax to call to determine the group, logged in user belongs to.
We can do it through Business rules and client script using g_scratchpad which is a simple way to determine.
Thank you,
Arkesh