Display extended table fields in form layout

hetaldoctor
Kilo Expert

Hi

I can see that we can display extended table fields in 'List layout'

But is there any way i can display extended table fields in 'Form Layout'?

Regards

Hetal

14 REPLIES 14

nitin_kumar
Mega Guru

Go to form layout and select the field reference field which contains the fields you need, then click on the tree icon and you will the list of fields on that table.\



Screen Shot 2017-02-01 at 12.25.12 PM.png



Screen Shot 2017-02-01 at 12.27.04 PM.png


Thanks,


Nitin.



PS : Mark answer as correct, helpful or like based on the impact


Hi Nitin


I dont extended tabled field not the reference fields


e.g. in task form i want to view incident table's outage fields


Any thoughts around that


Regards


Hetal


Hetal means extended fields, not reference fields.



E.g. from Server form, display fields on Windows Server CI (which extends Server) table.



ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

Hello Everyone I have found the solution using Script     Please mark as helpful and hit like



--------------------------------------------------Adding field to formlayout of all child tables using script-------------------------------------------------------------






var tu = new TableUtils("u_test");             //base table name


var classes = tu.getHierarchy();  


gs.include("j2js");  


var jsClasses = j2js(classes);                       //get all child table as well as base table


var arr=[];  


var gr= new GlideRecord('sys_ui_section');  


gr.addQuery('name', 'IN', jsClasses);  


gr.addEncodedQuery('view=Default view^captionISEMPTY');  


gr.query();  


while(gr.next()){  


arr.push(gr.getValue('sys_id'));               //push the sys_id of the ui section with empty caption




}



for (i=0; i < arr.length; i++){  


var gr1= new GlideRecord('sys_ui_element');  


gr1.initialize();  


gr1.sys_ui_section=arr[i];  


gr1.position=-1;                                         //position of the field on form


gr1.element='u_final';                           //field   to be added on all form layout


gr1.insert();  



 


}  






----------------------------------------------------------------------------------------------------------------------------------------------------


mackinley
Tera Expert

Our solution to this can be found: https://www.servicenow.com/community/developer-forum/how-to-get-extended-table-fields-on-parent-tabl...

 

Basically we created another column on the table that is a reference to the extending/child table and maintain its value via a business rule. Then we just use that new field to get display the fields we want on the form view.

 

EX Business Rule Advanced Script:

 

(function executeRule(current, previous /*null when async*/) {
  var extendingRecord = null;

  var extendingRecordGr = new GlideRecord('extending_table');
  if(extendingRecordGr.get(current.base_table.sys_id)) {
    extendingRecord = current.base_table;
  }

  current.u_extending_record = extendingRecord;
})(current, previous);