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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Form method event handler problem

(0) ShareShare
ReportReport
Posted on by 55

Hello Community,

I'm struggling with a form method event handler and was hoping to get some advice.

Form method VendEditInvoice.setLineFields() turns some fields non-editable and I need to change that.

This is my approach, but i'm getting the error below :

[PostHandlerFor(formStr(VendEditInvoice), formMethodStr(VendEditInvoice, setLineFields))]
public static void VendEditInvoice_SetLineFields_Post(XppPrePostArgs args)
{
FormRun form = args.getThis();

FormStringControl scPurchParmLineItemId = form.design().controlName(formControlStr(VendEditInvoice, PurchParmLine_ItemId));

scPurchParmLineItemId.allowEdit(true);

}

Error : The instance method designated by argument does not exist

The method does exist, but for some reason it does not seem to qualify as a instance method although it is not static.

Any idea how to get this to work or a work around to achieve the goal ?

Thanks

Darrell

I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    The method is not part of the form, it's part of the form data source which is a separate class.

    There's not method called setLineFields in the form itself. You will notice the difference if you try to create event handler for a data source event (by right click menu).

    I'm not sure if you can create event handlers for form data source methods. At least the right click menu in form designer doesn't allow it.

    I recommend you to try Chain of Command instead.

  • Darrell Crews Profile Picture
    55 on at

    Thanks, I tried CoC already and got the error 'setLineFields is not a chain of command method'.

  • nmaenpaa Profile Picture
    101,166 Moderator on at

    Hi Darrell,

    any chance you could share that CoC code?

  • Suggested answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    By the way, since setLineFields method is called from active method of the data source, you could use CoC or event handler to run your code after the standard active method.

  • Darrell Crews Profile Picture
    55 on at

    I tried this (setLineFields is not a CoC method)

    [ExtensionOf(classStr(VendEditInvoice)]

    final class VendEditInvoice_Extension

    {

       public void setLineFields()

       {

           next setLineFields();

           vendInvoiceInfoLine_ds.object(fieldNum(VendInvoiceInfoLine, ItemId)).allowEdit(true);

       }

    }

    and then this (vendInvoiceInfoLine_ds not in scope)

    [ExtensionOf(formDataSourceStr(VendEditInvoice, VendInvoiceInfoLine))]

    final class VendEditInvoice_Extension

    {

       public void setLineFields()

       {

           next setLineFields();

           vendInvoiceInfoLine_ds.object(fieldNum(VendInvoiceInfoLine, ItemId)).allowEdit(true);

       }

    }

  • Verified answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    Instead of vendInvoiceInfoLine_ds you should be able to access the ds with "this" (since you are augmenting the data source class).

    Anyway plan b would be to run your code after active method of the ds.

  • Suggested answer
    Frank Bruemmer Profile Picture
    354 on at

    Darrell,

    this should do it. This.object(..) should get you any form control :

    [ExtensionOf(formDataSourceStr(VendEditInvoice, VendInvoiceInfoLine))]

    final class VendInvoiceInfoLineForm_Extension

    {

       public void setLineFields()

       {

           next setLineFields();

           this.object(fieldNum(VendInvoiceInfoLine, ItemId)).allowEdit(true);      

       }

    }

    Best regards

    Frank

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 658

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 468 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 333 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans