web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

FormDataFieldEventHandler not updating field in D365 F&O

(2) ShareShare
ReportReport
Posted on by 196
Hi,
I have a form in D365 F&O with a field 'Object' in table 'EntAssetRequestTable'. 
I want to update 'CIMDTAssetDepartmentCode' based on the selected Object from 'EntAssetObjectTable' whenever the Object field is modified.
Here is my code:
[FormDataFieldEventHandler(formDataFieldStr(EntAssetRequestTable, RequestTable, Object), FormDataFieldEventType::Modified)]
public static void Object_OnModified(FormDataObject sender, FormDataFieldEventArgs e)
{
    EntAssetRequestTable requestTable = sender.datasource().cursor();
    if (requestTable.Object)
    {
        EntAssetObjectTable assetObject = EntAssetObjectTable::findRecId(requestTable.Object);
        if (assetObject && assetObject.CIMDTAssetDepartmentCode)
        {
            requestTable.CIMDTAssetDepartmentCode = assetObject.CIMDTAssetDepartmentCode;
        }
    }
}
Problem: The modified event is not updating the 'CIMDTAssetDepartmentCode' field on the form. 
It seems the event is not firing or the form is not refreshing.
I want to know:
1. Am I using FormDataFieldEventHandler correctly?
2. How can I ensure the field value is updated on the form when Object is changed?
Thanks!
 
Categories:
I have the same question (0)
  • Martin Dráb Profile Picture
    237,807 Most Valuable Professional on at
    What you need to do is using the debugger to check what happens in your code.
    In my opinion, it works as designed and it sets the value if found; you just don't see it in the form. Debugging will tell you whether it's the case or not, therefore you'll know what to fix.
  • Aditya Pal Profile Picture
    196 on at
    @Martin DrábI have checked using the debugger, and the value is not being saved to the database either. It seems that the code is not updating the data source as expected.
     
  • Martin Dráb Profile Picture
    237,807 Most Valuable Professional on at
    That's great that you used the debugger, now please tell us what you found there. It should have told you whether your code successfully sets the expected value to CIMDTAssetDepartmentCode field or not.
     
    Your code indeed doesn't save anything to database; it just sets a value of field. The user may later save the record, or decide to leave it without saving. It would be a bug if your event handler tried to save the record.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 522 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans