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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Call form extension method on datafield event handler

(1) ShareShare
ReportReport
Posted on by 8
Hello everybody, 
 
I have added FieldA on ProjTable table and eventually in the form. 
I need to run some logic when the field is modified on the form.
So, I have created MethodA on ProjTable_Form_Extension class and I am trying to call it from the data field event handler.
Below the code:
 
  [FormDataFieldEventHandler(formDataFieldStr(ProjTable, ProjTable, FieldA), FormDataFieldEventType::Modified)]
    public static void FieldA_OnModified(FormDataObject sender, FormDataFieldEventArgs e)
    {
        FormDataSource  projTable_ds   = sender.datasource() as FormDataSource;
        FormRun              formRun         = sender.datasource().formRun() as FormRun;
        ProjTable             projTable         = projTable_ds.cursor();
       
            formRun.methodA();
        }
    }
 
[ExtensionOf(formStr(ProjTable))]
final class ProjTable_Form_Extension
{
    public void methodA()
    {
          //logic here
    }
}
 
When I modify the field on the form, I get the below error:  FormRun object does not have method 'methodA'.
 
Can anybody help me, please? 
Thanks in advance!
I have the same question (0)
  • Martin Dráb Profile Picture
    238,208 Most Valuable Professional on at
    A better approach will be using a CoC extension of the data source and referring the the form by element variable.
  • Suggested answer
    Waed Ayyad Profile Picture
    9,047 Super User 2025 Season 2 on at
    Hi,
     
    Use the FormDataSourceField COC and add your method there.
     
    [ExtensionOf(formDataFieldStr(ProjTable, ProjTable, FieldA))]
    final class XXXProjTable_ProjTableFieldA_Extension
    {
        public void modified()
        {
            FormDataObject formDataObject = any2Object(this) as FormDataObject;
            FormDataSource formDataSource = formDataObject.datasource();
    
            next modified();
    ​​​​​​​ this.MethodA(); } public void methodA() { //logic here } }
    Thanks,
    Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue
  • Suggested answer
    Waed Ayyad Profile Picture
    9,047 Super User 2025 Season 2 on at
    Hi,

    Is your issue resolved?  If yes, mark the answers that helped you as verified.

    Thanks
    Waed Ayyad
  • Waed Ayyad Profile Picture
    9,047 Super User 2025 Season 2 on at
    Hi,

    Is your issue resolved?  If yes, mark the answers that helped you as verified.

    Thanks
    Waed Ayyad

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

News and Announcements

Season of Giving Solutions is Here!

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
Abhilash Warrier Profile Picture

Abhilash Warrier 791 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

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

#3
Martin Dráb Profile Picture

Martin Dráb 333 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans