How to show UI action to only few Roles
						
					
					
				
			
		
	
			
	
	
	
	
	
- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
01-17-2023 03:41 AM - edited 01-17-2023 03:42 AM
Hi ,
i have created one UI Action on incident Table to created child tasks. and the Button ' create task' should be visible to only for few users who is having few custom roles.
And i am aware that we can achieve this if we give"gs.hasRole('contract_manager') " in the condition field in UI action. But since we have many conditions we do not have any space left to give this in the condition field.
Can anyone please help me with the script to achieve this?
- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
08-15-2024 04:48 AM - edited 08-15-2024 04:49 AM
Dear @Purushotham9963 ,
'we have many conditions we do not have any space left to give this in the condition field.'
There are 2 ways you can over come when you have no space left on condition.
1 Easy way :
Create a duplicate ui of the existing UI Action and on the duplicate UI action remove all the condition and place only the condition for which there was no space left.
2. Scripted Way:
Create a script include with all the conditions and call the script include in UI action.
Now the choice is yours... 🙂
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
08-15-2024 05:31 AM
#1 won't work if the logic is all ANDs and not ORs because it's evaluated separately - a simple example, if you have current.state == 3 and gs.isMemberOf(current.assignment_group) and you separate this into two different actions, the UI action will show any time the state is 3 regardless of whether the logged in user is a member of the assignment group. The second action will also show for anyone who is a member of the assignment group, so those people will see two UI actions and not know the difference.
It also means you are duplicating code in more than one place which becomes harder to maintain over time.
