UI action with condition if current user if member of at least 1 group in list field type

kylem1
Tera Guru

Below condition works only if current user is member of each group selected. I am looking for a condition where current user is member of only 1 of the selected groups.

gs.hasRole(DemandUtil.getDemandRole('manager',current.getTableName())) && current.state == 1 && gs.getUser().isMemberOf(current.getValue("u_new_function"))

1 ACCEPTED SOLUTION

asifnoor
Kilo Patron

Here is the script include which you can use.

var MyScriptInclude = Class.create();
MyScriptInclude.prototype = Object.extendsObject(AbstractAjaxProcessor, {
	checkUser: function(groups){
                //assuming groups are passed as a string with comma separated.
		var groups_arr = groups.split(",");
		for(i=0;i<groups_arr.length;i++) {
			if(gs.getUser().isMemberOf(groups_arr[i])) {
				return true;
			}
		}
		return false;
	},
	type: 'MyScriptInclude'
});

And you can call in your UI action like this.

gs.hasRole(DemandUtil.getDemandRole('manager',current.getTableName())) && current.state == 1 && new MyScriptInclude().checkUser(current.getValue("u_new_function"))

Mark the comment as a correct answer and helpful if it helps.

View solution in original post

3 REPLIES 3

SanjivMeher
Kilo Patron
Kilo Patron

You would need a script include for that.

There is no OOB function to check that.

In the script, you would need to query the sys_user_grmember table and then return the group id, user belongs to


Please mark this response as correct or helpful if it assisted you with your question.

asifnoor
Kilo Patron

Here is the script include which you can use.

var MyScriptInclude = Class.create();
MyScriptInclude.prototype = Object.extendsObject(AbstractAjaxProcessor, {
	checkUser: function(groups){
                //assuming groups are passed as a string with comma separated.
		var groups_arr = groups.split(",");
		for(i=0;i<groups_arr.length;i++) {
			if(gs.getUser().isMemberOf(groups_arr[i])) {
				return true;
			}
		}
		return false;
	},
	type: 'MyScriptInclude'
});

And you can call in your UI action like this.

gs.hasRole(DemandUtil.getDemandRole('manager',current.getTableName())) && current.state == 1 && new MyScriptInclude().checkUser(current.getValue("u_new_function"))

Mark the comment as a correct answer and helpful if it helps.

Thank you for the assistance with this answer. I just had the opportunity to test and verified it does work.

Thank you for helping the community, asifnoor!