Wednesday, 4 January 2023

Form data source modified field event handler in D365FO

 

Below code shows how to get buffer from form data source field event handler(modified field) and update values as per the requirement


/// <summary>
/// Logic that displays the end time of the day
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormDataFieldEventHandler(formDataFieldStr(BankStatementTable,
BankStmtISOAccountStatement, ToDateTime),
FormDataFieldEventType::Modified)]
public static void ToDateTime_OnModified(FormDataObject sender,
FormDataFieldEventArgs e)
{
    FormDataSource BankStmtISOAccountStatement_ds =
    sender.datasource();
    BankStmtISOAccountStatement bankStmtISOAccountStatement =
    BankStmtISOAccountStatement_ds.cursor();
    TimeOfDay secondsElapsed;
    secondsElapsed = 86399;
    if(!bankStmtISOAccountStatement.ToDateTime)
    {
      bankStmtISOAccountStatement.ToDateTime =
      DateTimeUtil::newDateTime(DateTimeUtil::getSystemDate
     (DateTimeUtil::
      getUserPreferredTimeZone()),
      secondsElapsed);
    }
    else
    {
      bankStmtISOAccountStatement.ToDateTime = 
      DateTimeUtil::newDateTime(DateTimeUtil::date
      (bankStmtISOAccountStatement.ToDateTime),
      secondsElapsed);
    }
}

No comments:

Post a Comment

Filtering Company-Specific Product Templates - SysRecordTmpTemplate lookup

Hi Techies - Recently I have come across a requirement where I needed to display product templates specific to a selected company for a give...