If you have many condition for a UI script, how do you execute it?

Rain Vaine
Kilo Sage

Hello experts,
Hoping for advice in this one. I know that it is possible to use the condition field to limit when to show the UI action but I don't know how to do it if the condition is so long. If the condition is so long, it is not all going through in the condition field. it seems there is a limit to the condition field. Is it other approach on this>
This is a sample condition scenario:

// Existing condition
!(current.isNewRecord() && !current.canCreate()) && current.canWrite() &&

// Additional conditions
!(
(
// Condition 1: state is 7, view is "default", and user is not an admin
current.state == 7 && RP.getParameterValue('sysparm_view') == '' && !gs.hasRole('admin')
) ||
(
// Condition 2: incident_state is 7, view is "ess", and user is not an admin
current.incident_state == 7 && RP.getParameterValue('sysparm_view') == 'ess' && !gs.hasRole('admin')
)
)
Additionally i also want to add a condition to check if the caller_id is the one viewing the form before the UI action is displayed. Is it all possible to execute in the conditions?
By the way we cannot use the related list for views below, since the UI action is still supposed to show for certain state and admin users.

Regards,
Vaine

2 REPLIES 2

anshul_goyal
Kilo Sage

Hi @Rain Vaine,

You can use a Script Include within the UI Action. Call the Script Include in the UI Action's condition field, passing the 'current' object as an argument to the function, and define your conditions within the Script Include.

Please mark my answer as Helpful and Accepted, if it works for you in any way!

Thanks

Hello,
Sorry but do you also any idea idea on a sample script include, even if it is a simple logic. 

Regards,
Vaine