how to populate incident number in a custom

raom
Kilo Explorer

Hi Team,

I have one parent table and having another custom form/table as a related list in the parent table. But here I did not find any matching number/id which is common from both the tables and also the custom table(from the related list) is extending from the parent table. I have created a new field in child custom table to populate the parent table record number. Now I would like to populate a record number from parent table into a custom table when I click on New button from the related list.

Please help on this with the possibilities to achieve this. Appreciate your help.

Thanks,

Rao

12 REPLIES 12

raom
Kilo Explorer

Hi Team,


Typo from the above message. The child table is not extending from the parent table, may be that is the reason there is no matching id in the custom table.


I think you can create another reference field on your child table referencing to parent table.


Hi Shishir,


Thank you for your quick reply. Yes, I have created a new reference field on the child table and given parent table as reference table, now this field is allowing to select parent table records manually. But here when ever we click on New button on the child table (from the related list), it should auto populate the record number(from parent table) into the field on the child table.



Thanks,


Rao.


Hi Rao,



Please try in this way then.



I assume you have a string field (say child_num) on you child table to populate the parent table number.



Please create a Display Business rule on your child table (example: kb_knowledge) and capture the number in g_scratchpad from parent table (example: incident)



find_real_file.png


find_real_file.png



(function executeRule(current, previous /*null when async*/) {


  var gr = new GlideRecord('<YOUR PARENT TABLE NAME>');


  gr.get(parent.sys_id);


  g_scratchpad.number = gr.number;


})(current, previous);



************************************************************************************************



find_real_file.png



After that create a onLoad client script on your same Child Table to set the value in child_num field.



function onLoad() {


  if(g_form.getValue('child_num') == '')


  {


  g_form.setValue('child_num', g_scratchpad.number);


  }


}



I tried and it worked, Hope this will help you as well.



Please let me know if provided information is good enough to proceed further, please provide your feedback to help the community.