Need to visible "Add" button in related list in problem form when state is closed

Asha Pathak
Tera Contributor

When state is new , it shows the Add button in related list

AshaPathak_0-1711913734784.png

But when state is closed , it does not show the Add button on related list

AshaPathak_1-1711913848927.png

 


Is there any way to show Add button in related list when state is closed

 

2 ACCEPTED SOLUTIONS

Hi @Asha Pathak I am using OR condition here so as long as the parent table is problem, the 1st condition (parent.sys_class_name == 'problem') will execute and will ignore the other condition (parent.active == true), for other tables the parent.active will be true. this way there is no impact for other tables and condition works as expected.

 

Does it work? If yes please accept the solution:)

Regards
Harish

View solution in original post

HI @Asha Pathak after checking itseems OOB servicenow you cannot add a CI to the closed records, we would need to do a changes to the OOB script include AssociateCIToTask.

 

Modified script:

    script include: AssociateCIToTask
function to modify: _isValidTask
    _isValidTask: function(id) {
        var gr = new GlideRecord('task');
        //return gr.get(id) && gr.active; // need to remove gr.active here to add Ci
        gs.info("ID==>"+ gr.get(id));
        return gr.get(id);
    },
HarishKM_0-1712109175219.png

After modifying the above function CI gets added to the closed records

HarishKM_1-1712109206367.png

 

Regards
Harish

View solution in original post

26 REPLIES 26

Harish KM
Kilo Patron
Kilo Patron

Hi @Asha Pathak the OOB UI action "ADD" has a condition where it checks parent.active == true in below screenshot which hides the add button when problem state is resolved or closed , because when problem is resolved or closed active field becomes false and the condition evaluates to true which hides the Add button.

 

you would need to modify this OOB condition

 

HarishKM_0-1711937092750.png

 

Regards
Harish

Hello @Harish KM 
Thank you! But it is for only Change request and service offering .
For incident , Affected CIs, there are now condition as  parent.active == true

For cmdb_ci , condition is

AshaPathak_2-1711961929896.png

For Incident

AshaPathak_3-1711961977739.png

How to add condition

 

Hi @Asha Pathak can you paste the script include of the function canShowRelatedListUiAction here, you would need to modify the script accordingly to show button

Regards
Harish

Hi @Asha Pathak I checked OOB script include and found out the below function is called into incidentUtils script include, you would need to modify BulkAddIncidents script include and remove parent.active == true from below script for add button to be visible

HarishKM_1-1711963641296.png

 

HarishKM_0-1711963572259.png

 

Regards
Harish