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

Community site session details

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

How to call customized form datasource method in form datasource extension

(0) ShareShare
ReportReport
Posted on by 577

I extend purchline datasource in purchtable form as below

[ExtensionOf(formDataSourceStr(PurchTable,PurchLine))]
final class PurchTable_PurchLine_Extension
{
    public boolean method1()
    {
        ...
        return true;
    }
}

And, I call the my form datasource method under form control event hander.

/// 
    ///
    /// 
    /// 
    /// 
    [FormDataFieldEventHandler(formDataFieldStr(PurchTable, PurchLine, ConfirmedDlv), FormDataFieldEventType::Modified)]
    public static void ConfirmedDlv_OnModified(FormDataObject sender, FormDataFieldEventArgs e)
    {
        Object PurchLine_DS = sender.datasource().formRun().dataSource(formDataSourceStr(PurchTable, PurchLine));

        PurchLine_ds.method1();
    }

And the error is thrown

FormDataSource object does not have method 'method1'.

I have the same question (0)
  • Tony Mok Profile Picture
    577 on at
    RE: How to call customized form datasource method in form datasource extension

    Nikolaos Mäenpää,

    I move to form root level, thanks.

  • Tony Mok Profile Picture
    577 on at
    RE: How to call customized form datasource method in form datasource extension

    Sukrut Parab,

    I change it to Object PurchLine_DS = sender.datasource();

    The same error "FormDataSource object does not have method 'method1'." is thrown

  • Suggested answer
    Sukrut Parab Profile Picture
    71,699 Moderator on at
    RE: How to call customized form datasource method in form datasource extension

    Do you want purchline datasource ? If so , did u try sender.datasource() ?

  • Tony Mok Profile Picture
    577 on at
    RE: How to call customized form datasource method in form datasource extension

    Compare with previous purchline field, and update field values

  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: How to call customized form datasource method in form datasource extension

    Sorry, I missed that. In that case I think your scenario might not yet be supported in Chain of Command. Could you add your method to PurchLine table instead? Or on the form root level? What is the purpose of that method?

  • Tony Mok Profile Picture
    577 on at
    RE: How to call customized form datasource method in form datasource extension

    Nikolaos Mäenpää,

    Object PurchLine_DS is already declared as Object type.

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: How to call customized form datasource method in form datasource extension

    Cast the data source into Object type.

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

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

#1
Sohaib Cheema Profile Picture

Sohaib Cheema 823 User Group Leader

#2
André Arnaud de Calavon Profile Picture

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

#3
Martin Dráb Profile Picture

Martin Dráb 491 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans