UI Action visibility

subashds6515
Tera Contributor

Hi,

 

My UI Action Button visible only based on the below conditions. that are,

 

UI Action Name : Submit

Condition : 1. State = Draft

                    2. User has "Admin" role

                    3. Assigned To User

 

I have created somehow, can anyone guide me to achieve this.

I attached the screenshot for reference.

subashds6515_0-1692880804043.pngsubashds6515_1-1692880809857.png

 

 

3 ACCEPTED SOLUTIONS

Manmohan K
Tera Sage

Hi @subashds6515 

 

Add below code in Condition field

(Modify field name for state in your form if needed)

 current.state == 'draft' && (gs.hasRole('admin') || (current.assigned_to == gs.getUser()))

 

View solution in original post

Shreya Wani
Tera Guru
Tera Guru

Hi @subashds6515,

 

- To apply the conditions for the 'Submit' button, add the below code line in the 'Condition' field.

current.state == 'draft' && ( gs.hasRole('admin') || current.assigned_to == gs.getUser() )

- So only when the above conditions are met, the button will be visible. And onClick of the button, the field's 'u_choice_4' value will be set to 'submitted' and the form will get saved which you have mentioned in the script.

If you feel that I have assisted you in any manner, please mark my comment as helpful/correct.

For more information, check out the below product documentation.

https://docs.servicenow.com/en-US/bundle/vancouver-platform-administration/page/administer/list-admi...

 

Thanks,

Shreya Wani

View solution in original post

Mohith Devatte
Tera Sage
Tera Sage

HEllo @subashds6515 ,

you can try this in condition

 current.u_choice_4 == 'draft' && gs.hasRole('admin') && current.assigned_to == gs.getUserID()

Hope this helps 

Mark my answer correct if this helps you 

Thanks

View solution in original post

3 REPLIES 3

Manmohan K
Tera Sage

Hi @subashds6515 

 

Add below code in Condition field

(Modify field name for state in your form if needed)

 current.state == 'draft' && (gs.hasRole('admin') || (current.assigned_to == gs.getUser()))

 

Shreya Wani
Tera Guru
Tera Guru

Hi @subashds6515,

 

- To apply the conditions for the 'Submit' button, add the below code line in the 'Condition' field.

current.state == 'draft' && ( gs.hasRole('admin') || current.assigned_to == gs.getUser() )

- So only when the above conditions are met, the button will be visible. And onClick of the button, the field's 'u_choice_4' value will be set to 'submitted' and the form will get saved which you have mentioned in the script.

If you feel that I have assisted you in any manner, please mark my comment as helpful/correct.

For more information, check out the below product documentation.

https://docs.servicenow.com/en-US/bundle/vancouver-platform-administration/page/administer/list-admi...

 

Thanks,

Shreya Wani

Mohith Devatte
Tera Sage
Tera Sage

HEllo @subashds6515 ,

you can try this in condition

 current.u_choice_4 == 'draft' && gs.hasRole('admin') && current.assigned_to == gs.getUserID()

Hope this helps 

Mark my answer correct if this helps you 

Thanks