how to fetch value of a related list record and according to that Hide/show the UI action

Pratiksha Lang1
Kilo Sage

How to fetch value of a related list record and according to that Hide/show the UI action

For example: I have created a relationship between 2 tables. I want to check the related list field - result is empty, If it is empty then the UI action should be visible. otherwise it should not be visible. 

UI action created on table - Input ola table 

related list - ola score  table

 

PratikshaLang1_2-1681473152289.png

 

 

 

4 REPLIES 4

Prince Arora
Tera Sage
Tera Sage

@Pratiksha Lang1 ,

 

You need to write function in the script include as mentioned below:

 

 showUIAction: function(current) {
var relatedTable = new GlideRecord("related_table_Name");
relatedTable.addQuery("parent_table_field", current.sys_id);
relatedTable.query();
if(relatedTable.getRowCount() > 0){
return "false";
}else{
return "true";
}

},

 

And from the UI action, you need to call the script include as below:

 

new scriptIncludeName().functionName(current)  == "true"

 

PrinceArora_0-1681475435949.png

 

I hope you get the idea how to implement it!

 

If my answer solved your issue, please mark my answer as  Correct & 👍Helpful based on the Impact.

 

Thank You So Much for your help @Prince Arora it worked.

@Pratiksha Lang1 ,

 

You marked my answer helpful!

Please Accept it if it has answered you query, It would be helpful for future readers too.

Ian Mildon
Tera Guru

It is possible to do Related List queries via "addEncodedQuery" strings in Business Rules and/or Scheduled Jobs using "RLQUERY"

 

This script is an example of the syntax structure that I'm running in a scheduled job:

 

TriggerNotificationNew();

function TriggerNotificationNew() {

    var getAsset = new GlideRecord('alm_hardware');
    getAsset.addEncodedQuery('u_workstation_type=BCA^install_status=1^RLQUERYu_bca_health_check_log.u_asset_record,>=1^sys_created_onRELATIVELT@dayofweek@ago@60^ENDRLQUERY'); //* includes related list query
    getAsset.query();
    var list = [];
    while(getAsset.next()) {
        list.push(getAsset.serial_number.toString());     
    }
    var arrayUtil = new ArrayUtil();
    var answer = arrayUtil.unique(list);

    var getSNval = new GlideRecord('alm_hardware');
    getSNval.addQuery('serial_number', 'IN', answer);
    getSNval.query();
    while (getSNval.next()) {
        gs.eventQueue('send.bcahealthcheck.reminder', getSNval, getSNval.serial_number); //* would push the Serial Number as Parm1
    }
} 

 

It starts with the "RLQUERY" piece and then ends with the "ENDRLQUERY" piece