title: How can I auto populate a field based on other fields with X++?
body: <p>I am using D365 Finance and operations. I have a form and four fields in it. Every time I enter a new record of one of these three fields, their values should be concatenated and the combined text put to the 'Details' field which is the fourth field. I think I need to use onupdateevent for this but I do not know-how.</p>
  <p>I used onmodifyingfield event handler and it works but only when I enter and save the second record. I mean I save record and auto-populate does not work but when I save the second record and refresh the page I can see the auto-populated field in the first record. Here is my codes;</p>
  <pre><code>[DataEventHandler(tableStr(InventSite), DataEventType::ModifyingField)]
  public static void InventSite_onModifyingField(Common sender, DataEventArgs e)
  {
      MyTable myTable;
  
      update_recordset mytable setting Details = MyTable.Field1 + &quot;, &quot; + MyTable.Field2;
  </code></pre>
  <p>I would really be appreciated if anyone can help me with this.</p>