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 :
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
    101,172 Moderator on at

    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

  • veera seenivasan Profile Picture
    575 on at

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

  • nmaenpaa Profile Picture
    101,172 Moderator on at
    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
    575 on at

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

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

    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.

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 > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans