Need help to write a Script to enable conditonal UI Action (button)

Not applicable

Use case:- There should be a button (named as- Assigned Me) at the top, this button should only display to users who belongs to the selected assignment group mentioned below the Assignment group field in the incident record. Means when the logged in user selects the assignment group from the assignment group field and he belongs to that group then that button should be visible to him.

2 ACCEPTED SOLUTIONS

Not applicable

Hi @Community Alums ,

 

Create a UI action as below 

(Make sure you save the form once assignment group is selected to see UI hide/show logic)

HemanthM1_0-1724495916413.png

//Condition
gs.getUser().isMemberOf(current.assignment_group)

//script
current.assigned_to = gs.getUserID(); //set logged in user has assigned to
current.update(); //update

 

Hope this help!!!

 

 

View solution in original post

Not applicable

Hi @Community Alums 

 

Condition section is only to control button visibility (hide/show)

if you want to write multiple line then use &&, || conndition , if its multiple condition and does fit in the condition section use script include and call it from condition section

 

ex 1:  to check logged in user is part of the current assigment group and has ITIL role

gs.getUser().isMemberOf(current.assignment_group) && gs.hasRole("itil")

 

ex 2: To write multiple line of code using script include

gs.getUser().isMemberOf(current.assignment_group) && gs.hasRole("itil") && new checkCondition().sampleCode()

 

HemanthM1_0-1724573448216.png

 

script include:

HemanthM1_1-1724573512092.png

 

 

Hope this helps!!!

 

View solution in original post

4 REPLIES 4

Not applicable

Hi @Community Alums ,

 

Create a UI action as below 

(Make sure you save the form once assignment group is selected to see UI hide/show logic)

HemanthM1_0-1724495916413.png

//Condition
gs.getUser().isMemberOf(current.assignment_group)

//script
current.assigned_to = gs.getUserID(); //set logged in user has assigned to
current.update(); //update

 

Hope this help!!!

 

 

Not applicable

Hi @Community Alums ,

 

Unlike this case, what if I had to write multiple lines of code in the condition section? Can I write my conditions in the script section? Or is it only used for specifying click actions?

 

Thank you,

Pavan

Not applicable

Hi @Community Alums 

 

Condition section is only to control button visibility (hide/show)

if you want to write multiple line then use &&, || conndition , if its multiple condition and does fit in the condition section use script include and call it from condition section

 

ex 1:  to check logged in user is part of the current assigment group and has ITIL role

gs.getUser().isMemberOf(current.assignment_group) && gs.hasRole("itil")

 

ex 2: To write multiple line of code using script include

gs.getUser().isMemberOf(current.assignment_group) && gs.hasRole("itil") && new checkCondition().sampleCode()

 

HemanthM1_0-1724573448216.png

 

script include:

HemanthM1_1-1724573512092.png

 

 

Hope this helps!!!

 

Not applicable

Hi @Community Alums ,

 

Thank you. Unlike in this case, what if I had to write multiple lines of code for a condition, not just a single line? Can I use the script section to specify my condition, or is it only exclusive to specifying click actions?

 

Thank You,

Pavan