Related list

Linda Eju
Tera Contributor

How do i omit a New button on a related list When the list is not empty?

2 ACCEPTED SOLUTIONS

sanket mohite
Tera Expert

Open the related list table's UI actions search for the "new" ui action and on the new ui action form view uncheck the list banner button checkbox 

It will remove the new button from related list 

For e.g On the incidents form if you want to remove new ui action from child incident  related list then type incident.config > UI action> select the new ui action  button> on the new ui action form view uncheck the list banner button checkbox 

 

Note : As I was doing removing the new button from child incident i have navigated to incident table 

          If you want to remove from any other related list the table will be differ keep in mind

 

If my answer is helpful then  please mark it as helpful 

 

View solution in original post

Community Alums
Not applicable

Hi @Linda Eju ,

 

I checked your problem and tried in my PDI and it working fine for me 

Before : 

SarthakKashya2_0-1712819008231.png

After: 

SarthakKashya2_1-1712819047847.png

 

Right click on related list and click "List Control".

SarthakKashya2_2-1712819108933.png

 

Add below code and it will work 

SarthakKashya2_3-1712819152878.png

 

 

var answer ;
gs.log("Checck log incidnet 222 = " + parent.child_incidents);

if (parent.child_incidents <= 0) { //Do not remove the 'New' button
   answer = false ;
}
else { //Remove the 'New' button
   answer = true ;
}

answer ;

 

 

Please mark correct and helpful if it works for you

 

Thanks and Regards 

Sarthak

View solution in original post

4 REPLIES 4

Guido Bernuetz
Giga Guru

An idea:

  1. Create a before display business rule and calculate the number of the related records (use GlideAggregate)
  2. Put the value in g_scratchpad container
  3. Copy the global UI action "new" for related list to your specific table with the same action name
  4. In the condition line of the UI Action check g_scratchpad content.

NOT tested!

I am not a helpful hunter.
I will always try to give a meaningful and valid answer.

Tai Vu
Kilo Patron
Kilo Patron

Hi @Linda Eju 

You can do a simple query to validate if there're existing records associated to the parent or not.

Sample below.

var gr = new GlideRecord(current.getTableName());
gr.addQuery('task', parent.getUniqueValue());
gr.setLimit(1);
gr.query();
answer = gr.hasNext();

 

Incident Affected CIs

Screenshot 2024-04-11 at 13.35.14.png

Screenshot 2024-04-11 at 13.35.39.png

 

Cheers,

Tai Vu

sanket mohite
Tera Expert

Open the related list table's UI actions search for the "new" ui action and on the new ui action form view uncheck the list banner button checkbox 

It will remove the new button from related list 

For e.g On the incidents form if you want to remove new ui action from child incident  related list then type incident.config > UI action> select the new ui action  button> on the new ui action form view uncheck the list banner button checkbox 

 

Note : As I was doing removing the new button from child incident i have navigated to incident table 

          If you want to remove from any other related list the table will be differ keep in mind

 

If my answer is helpful then  please mark it as helpful 

 

Community Alums
Not applicable

Hi @Linda Eju ,

 

I checked your problem and tried in my PDI and it working fine for me 

Before : 

SarthakKashya2_0-1712819008231.png

After: 

SarthakKashya2_1-1712819047847.png

 

Right click on related list and click "List Control".

SarthakKashya2_2-1712819108933.png

 

Add below code and it will work 

SarthakKashya2_3-1712819152878.png

 

 

var answer ;
gs.log("Checck log incidnet 222 = " + parent.child_incidents);

if (parent.child_incidents <= 0) { //Do not remove the 'New' button
   answer = false ;
}
else { //Remove the 'New' button
   answer = true ;
}

answer ;

 

 

Please mark correct and helpful if it works for you

 

Thanks and Regards 

Sarthak