Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / Form Init method in D365
Finance forum

Form Init method in D365

(0) ShareShare
ReportReport
Posted on by 575

Guys,

While opening the VendInvoice info list page i need the info of all the Invoice Account but the value is not coming . Can you please give me some suggestion.

This is the code I tried out.

[PostHandlerFor(formStr(VendInvoiceInfoListPage), formMethodStr(VendInvoiceInfoListPage, init))]

    public static void VendInvoiceInfoListPage_Post_init(XppPrePostArgs args)
    {
        FormRun fr = args.getThis();
        Common common = fr.args().record();
        VendInvoiceInfoTable vendInvoiceInfoTable = common;
        Info(strFmt("%1",VendInvoiceInfoTable.InvoiceAccount));
    } 
 

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Form Init method in D365

    A general comment: could you please always make sure you share all the details that you can, when you are asking for help. "Does not work" doesn't contain much information. Was there an error? Did you get too many records? Did you get no records? The more you share, the better help you get.

    As Martin pointed out in another thread, post_init of the form might be too early in the process, since the query has not yet been executed.

    So maybe you could try to hook your code in the post event of executeQuery method of the form data source.

  • veera seenivasan Profile Picture
    veera seenivasan 575 on at
    RE: Form Init method in D365

    This code does not work for us. Can you please give some alternative or reference.

  • nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Form Init method in D365
    public static void VendInvoiceInfoListPage_Post_init(XppPrePostArgs args)
    {
        FormRun fr = args.getThis();
        FormDataSource fds = fr.dataSource();
    
        VendInvoiceInfoTable vendInvoiceInfoTable = fds.getFirst();
    
        while (vendInvoiceInfoTable)
        {
            info(strFmt("%1",vendInvoiceInfoTable .InvoiceAccount));
            vendInvoiceInfoTable = fds.getNext();
        } 
    } 

    Does this work for you?

    In general I don't know what you are trying to achieve but it sounds like it's not going to be a very good solution for performance.

    Imagine if your customer has 1 000 000 records in this table. Every time when they open the form your code would iterate the 1 000 000 records, taking many minutes.

    If you need help designing a better solution, you can share your business requirement and describe what you are actually trying to achieve.

  • veera seenivasan Profile Picture
    veera seenivasan 575 on at
    RE: Form Init method in D365

    To get all the Invoice Account. I followed the Above link but not able to achieve.

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Form Init method in D365

    All invoice accounts of the list page? Or what?

    Here you can find how to show Invoice account of the active record: community.dynamics.com/.../311551

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans