how to use relationship in the related list

Simona6
Tera Contributor

requirement is to display all the attachment file related to the record in the related list.

CUST001 have string field loss number=XYZ and CUST002 having loss number=XYZ

current record:CUST001

Related list: Document =CUST001.

 if the loss number on custom record is empty then related list document will show all document related to current record.

if the loss number is something(e.g XYZ) then related list document will show all document related to both record(e.g CUST001 and CUST002).

This is implemented but when i click on 'New' button from related list document it doesn't automatically fill the reference field CUST.

below 'Query with' code is used in relationship:

if(parent.u_loss_case!=""){////in this scenario when click on NEW button it  doesn't fill custom record reference i.e CUST001.
         var spc = new GlideRecord('u_custom');
         spc.addQuery('u_loss_case', parent.u_loss_case);
         spc.query();
         var sysIDs = [];
         while (spc.next())
            sysIDs.push(''+spc.sys_id);
           
         current.addQuery('document_for', sysIDs);
         
      }
      else{ ///in this scenario when click on new button it automatically fill the custom record reference.
        current.addQuery('document_for', parent.sys_id);
       
      }
 
How to fix when click on new button the reference field 'Document for' automatically fill with current record number in both scenario or any other way to fix it
0 REPLIES 0