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, ...
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,160 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,160 Moderator on at

    Hi Darrell,

    any chance you could share that CoC code?

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 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,160 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

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 660 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 307 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans