Autopopulate field from incident form on new problem form.

arohi
Kilo Expert

Hi All,

In incidents the problem_id field is a reference to the problem table. When clicking on the magnifying glass a list of problem records appear. If I click on the NEW button from this list a form appears,i want to autopopulate some fields such as configuration item, short description, Impacted service from previous incident form.

Any suggestions.

Thanks in advance.

7 REPLIES 7

Shishir Srivast
Mega Sage

Hi Arohi,



You can create Display BR to capture the values from incident form in g_scratchpad and the use then in onLoad client script to auto populate the data when New Problem form loads.



Please try in this way:



Kindly TRY with below code in Displace BR on Problem Table.



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


  // Add your code here


  var gr = new GlideRecord('incident'); // Please enter the parent table name


  gr.get(parent.sys_id);


  g_scratchpad.value1 = gr.getValue('<name of the reference field from parent table>');


  g_scratchpad.value2 = gr.<name of the string field from parent table>;


})(current, previous);



Client Script: on Problem Table.



function onLoad() {


  //Type appropriate comment here, and begin script below


  if(g_form.isNewRecord()){


  g_form.setValue('<name of the string field on child table>', g_scratchpad.value1 );      


  g_form.setValue('<name of the string field on child table>', g_scratchpad.value1 );    


  //g_form.setValue('<field name of Reason>', 'Release');    


  }


}


Hi Shishir,


Thanks for your quick response, but this is not working, its not fetching values.


Hi Arohi,



I think that's not possible because when you click on NEW button it's open a new Problem Form to create new Problem Record which is not related to Parent table (Incident). In that case you have to add Problem table in Related list and click New Problem record from there, in that case that will related to parent table and fields from the parent table to child table can be populated.



find_real_file.png



when you create from related list table it gets relate/referenced to parent table.


find_real_file.png


oops!! Thank you for this clarification.