ui action condition

zx
Tera Contributor
I want to add a condition to the 'update' button , but the condition column in the update ui action is already filled. What should I do in this situation?
3 ACCEPTED SOLUTIONS

Sid_Takali
Kilo Patron
Kilo Patron

Hi @zx For easier maintainability, keep the condition as short as possible. If the computation is complex, it is difficult to read and understand. Rather than increasing the field length, consider putting your logic in a script include. For example, rather than something like this... 

https://www.servicenow.com/community/developer-forum/increase-the-max-length-hof-condition-in-ui-act...

 

View solution in original post

Community Alums
Not applicable

Hi @zx 

You can probably append your condition and call the script include in the condition column.

Mark my response as helpful or accepted.

Thanks

View solution in original post

Rajesh Chopade1
Mega Sage

hi @zx 

You can use logical operators (like && for AND or || for OR) to combine the existing condition with your new condition.

Suppose existing code is:

current.state == 'open'

 

you can update the condition like: 

current.state == 'open' && gs.hasRole('admin')

 

For complex conditions, consider moving the logic to a Script Include or a Business Rule for better maintainability and readability.

 

i hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.

thank you

rajesh

View solution in original post

5 REPLIES 5

Sid_Takali
Kilo Patron
Kilo Patron

Hi @zx  You can append your condition using && like refer this 

(new GlideRecord(current.getTableName())).canWrite() && RP.isOneToMany() && !RP.getListControl().isOmitEditButton() 

Sid_Takali
Kilo Patron
Kilo Patron

Hi @zx For easier maintainability, keep the condition as short as possible. If the computation is complex, it is difficult to read and understand. Rather than increasing the field length, consider putting your logic in a script include. For example, rather than something like this... 

https://www.servicenow.com/community/developer-forum/increase-the-max-length-hof-condition-in-ui-act...

 

Community Alums
Not applicable

Hi @zx 

You can probably append your condition and call the script include in the condition column.

Mark my response as helpful or accepted.

Thanks

Rajesh Chopade1
Mega Sage

hi @zx 

You can use logical operators (like && for AND or || for OR) to combine the existing condition with your new condition.

Suppose existing code is:

current.state == 'open'

 

you can update the condition like: 

current.state == 'open' && gs.hasRole('admin')

 

For complex conditions, consider moving the logic to a Script Include or a Business Rule for better maintainability and readability.

 

i hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.

thank you

rajesh