How to show an ui action on incident only if has at least one open child incident?

akshay parekar1
Tera Contributor

Hi All,

   I have a requirement where i have to show an ui action on incident , only if

- That incident is in open state (New, in progress)

- That incident has at least one open child incident in related list (Child Incidents)

I was not sure how to add condition in ui action for related list, please let me know how to do this.

Thanks!!

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hi @akshay parekar1,

You can add in that UI Action's condition as below:

(current.state == IncidentState.NEW  || current.state == IncidentState.IN_PROGRESS) && new check_ui_action().checkButtonVisibility(current)

And in your Script include 'check_ui_action':

checkButtonVisibility: function(record) {
        var gr = new GlideRecord('incident');
        gr.addQuery('parent_incident', record.getUniqueValue());
        gr.query();
        if (gr.next()) {
            return true;
        }
        return false;
    },

  

View solution in original post

3 REPLIES 3

Ahmmed Ali
Mega Sage

Hello @akshay parekar1 

 

You need to write one script include to check if the current incident has any active child incident and return true or false based on that. Then call that script include in condition field of the UI action.

 

Thanks,

Ali

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

bhavishapadia
Kilo Sage

Hi,

 

You can use script include in condition if it returns true then UI Action is visible. In the script include check multiple condition and return the statement with all condition in AND or OR condition.

Community Alums
Not applicable

Hi @akshay parekar1,

You can add in that UI Action's condition as below:

(current.state == IncidentState.NEW  || current.state == IncidentState.IN_PROGRESS) && new check_ui_action().checkButtonVisibility(current)

And in your Script include 'check_ui_action':

checkButtonVisibility: function(record) {
        var gr = new GlideRecord('incident');
        gr.addQuery('parent_incident', record.getUniqueValue());
        gr.query();
        if (gr.next()) {
            return true;
        }
        return false;
    },