Show UI action button based on logged in users assignment group

Raghesh
Giga Expert

Hi,

We have one Catalog request with three catalog tasks and UI action button "Close Task" on the catalog tasks. 

Now the requirement is on the second catalog task, to show the "Close Task" UI action button only for some assignment group members and for the rest of the assignment group members this should not be visible.

Apart from this there is a STATE field in the catalog task, there also we need to hide "Close Complete" status as per the above condition.

Note: All the above should be applicable only to Catalog Task2.

 

find_real_file.png

Any ideas or suggestions highly appreciated.

regards,

Raghesh

 

1 ACCEPTED SOLUTION

Hi,

use this

var ShowCloseTask = Class.create();
ShowCloseTask.prototype = Object.extendsObject(AbstractAjaxProcessor, {

	initialize: function(current){
	},

	checkCondition: function(current){

		if((gs.getUser().isMemberOf('Testing & Quality') || gs.getUser().isMemberOf('IT ServiceDesk & EUS') || gs.getUser().isMemberOf('Problem Manager')) && current.request_item.cat_item == '325ada7adbac8490d71941efaa9619bb' && current.short_description.indexOf('Task 2 : Test')){
			return true;
		}
		else {
			return false;
		}

	},

	type: 'ShowCloseTask'
});

UI Action condition:

new ShowCloseTask().checkCondition(current);

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

14 REPLIES 14

Anil Lande
Kilo Patron

Hi,

You can use script include function to evaluate all criteria for your task.

Make a script include call and check all values like sc_task state, short description and logged IN user membership. return true or false if condition doe not match.

Check below links for more information and how to call script include function:

https://community.servicenow.com/community?id=community_blog&sys_id=2c6ceaa1dbd0dbc01dcaf3231f96190c

https://community.servicenow.com/community?id=community_question&sys_id=976a83e9db5cdbc01dcaf3231f96...

 

Thanks,
Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Hi Anil,

I got your point as you are asking to create a script include to check the conditions and then call it from the UI action condition.

But I have very little knowledge on the scripting side, so could you please help with a template/sample script. 

regards,

Raghesh

 

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

please start from your side and it would learning for you as well

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

I have tried a script include but not sure if it is correct or not and giving some error.

var ShowCloseTask = Class.create();
ShowCloseTask.prototype = Object.extendsObject(AbstractAjaxProcessor, {

initialize: function(){
var checkMemberOf = new GlideRecord('sc_task');

if(gs.getUser().isMemberOf('Testing & Quality','IT ServiceDesk & EUS','Problem Manager') && current.request_item.cat_item == '325ada7adbac8490d71941efaa9619bb' && desc.indexOf('Task 2 : Test'));


return true;
}
else {
return false;
}

{
answer = true;
}
type: 'ShowCloseTask'
});

 

 

find_real_file.png

regards,

Raghesh