Related list ui action button

Kusuma2
Kilo Guru

Hi All,

I would like to make the Button(Custom Button named"Relate" )  present in the Related list to be visible,    if the Related list has no empty Records.

If there are no records in related list(EMTY) I would like to hide that Button.

(Or)

Then button should be visible only when you select any of the records in the Related list.

 

Thanks,

9 REPLIES 9

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Aj,

you will have to write script include and call that in the condition field of UI action and then show/hide the button.

Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thanks for the Reply:

I am new to servicenow . Could you please guide me to hide this button.

find_real_file.png

How to check in script include that the related list has empty records.

Hi Aj,

Steps below. you must be having a field on Catalog Item table which refers to the current form.

In my example below: I have added the button name "Sample Button" on Catalog Variable Set table(io_set_item) which has a field which refers to Catalog item. The button would be shown/hidden in related list.

The button will be shown only when there is at least 1 variable set tagged to that catalog item.

Script Include:

Name: TestFilter

API Name: global.TestFilter

Script:

var TestFilter = Class.create();
TestFilter.prototype = {
initialize: function() {
},

checkRecord: function(sysId){
gs.log("ANK 12 sysId is:"+sysId);
var gr = new GlideRecord('io_set_item');
gr.addQuery('sc_cat_item', sysId);
gr.query();
gs.log("ANK 12 row count is:"+gr.getRowCount());
if(gr.hasNext())
return true;
return false;
},

type: 'TestFilter'
};

 

UI Action:

Condition: new global.TestFilter().checkRecord(current.sc_cat_item.sys_id);

here I am passing the Catalog Item Sys Id so that I can query the Catalog Variable Set table to check if any variable set exists for this catalog item:

Testing:

1) Catalog Item having variable set: Button Shown

find_real_file.png

2) Catalog Item having no variable set: Button hidden

find_real_file.png

Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

I followed the steps suggested by you but still facing issue.