- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2018 07:22 AM
I have created one link on Story form using UI Action but i want that link to be visible when it matches below conditions :-
1) Story state should not be "Complete" or "Cancelled".
2) the assignee (the person to whom the story is assigned) should be a member of one group i.e. "Network Team".
but this condition "current.assigned_to.isMemberOf("Network Team") == true" is not working , why
current.state != 3 && current.state != 4 && gs.hasRole("itil") && current.assigned_to.isMemberOf("Network Team") == true
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2018 07:59 AM
DIsagree, saying 'state is not 3 and state is not 4' will work just fine.
the use of isMemberOf() is the problem here, it's a GlideUser method so you can't use it on the current object.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2018 07:38 AM
Hi Mahesh,
Sorry you cant write assigned_to condition like this. Call script include from ui action.
Here is a snippet
var assigned_to_user_null = Class.create();
assigned_to_user_null.prototype = Object.extendsObject(AbstractAjaxProcessor, {
ismember:function(){
var v_assigned_group=this.getParameter('sysparm_assigned_group');
var v_assigned_user=this.getParameter('sysparm_assigned_user');
var gr = new GlideRecord("sys_user_group");
gr.addQuery('sys_id', v_assigned_group);
gr.query();
if (gr.next()) {
var v_user=gs.getUser();
v_user=v_user.getUserByID(v_assigned_user);
return v_user.isMemberOf(gr.name);
}
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks,
Aman
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2018 07:41 AM
Hi Mahesh,
We never put && For the same field.
current.state != 3 && current.state != 4. This will always return false
So we should put this in OR condition.
current.state != 3 && current.state != 4.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2018 07:59 AM
DIsagree, saying 'state is not 3 and state is not 4' will work just fine.
the use of isMemberOf() is the problem here, it's a GlideUser method so you can't use it on the current object.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2018 08:16 AM
As stated, isMemberOf() is a GlideUser method. You can create a script include to query the sys_user_grmember table and set your UI Action condition to call it. Try this code:
UI Action condition: new isMember().membercheck(current.assigned_to);
Script Include:
Name - isMember
var isMember = Class.create();
isMember.prototype = {
initialize: function() {
},
membercheck : function (incAssgnVal){
var grMember = new GlideRecord("sys_user_grmember");
grMember.addQuery("user", incAssgnVal);
grMember.addQuery("group", '<sys id of group>');
grMember.query();
{
if(grMember.next()){
answer = true;
return answer;
}
else{
answer = false;
return answer;
}
}
},
type: 'isMember'
};
