Skip to main content

Notifications

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 6
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!
  • Waed Ayyad Profile Picture
    8,228 Super User 2025 Season 1 on at
    Call form extension method on datafield event handler
    Hi,

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

    Thanks
    Waed Ayyad
  • Suggested answer
    Waed Ayyad Profile Picture
    8,228 Super User 2025 Season 1 on at
    Call form extension method on datafield event handler
    Hi,

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

    Thanks
    Waed Ayyad
  • Suggested answer
    Waed Ayyad Profile Picture
    8,228 Super User 2025 Season 1 on at
    Call form extension method on datafield event handler
    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
  • Martin Dráb Profile Picture
    232,866 Most Valuable Professional on at
    Call form extension method on datafield event handler
    A better approach will be using a CoC extension of the data source and referring the the form by element variable.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,095 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,866 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans