Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

Customise standard sales confirmation report

(0) ShareShare
ReportReport
Posted on by 58

Hi,

I need to add a custom field in the sales confirmation report.

I found many reference but those are not working for my case,

If you have any idea or reference let me know.

thanks and regards,

Aathil Ameen P

  • Suggested answer
    Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    RE: Customise standard sales confirmation report

    Hi, Instead of writing code in processReport method of DP class, you can add your code in insert method of SalesConfirmHeaderTmp. You can use OnInserting EventHandler or CoC on insert method. This way you don't have to update all records.

    Both processRecords and Table insert method will work.

    SalesConfirmHeaderTmp.CustAccount = SalesTable::find(SalesConfirmHeaderTmp.SalesId).CustAccount;

  • Verified answer
    GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Customise standard sales confirmation report

    If your salesTable has Customer account value you can get it by adding select statement based on salesId relation between SalesTable and SalesConfirmHeaderTmp.

    [PostHandlerFor(classStr(SalesConfirmDP), methodStr(SalesConfirmDP, processReport))]
    public static void SalesConfirmDP_Post_processReport(XppPrePostArgs args)
    {
        SalesConfirmDP dpInstance = args.getThis() as SalesConfirmDP;
    
        SalesConfirmHeaderTmp salesConfirmHeaderTmp = dpInstance.getSalesConfirmHeaderTmp();
    
        SalesTable salesTable;
    
        ttsbegin;
    
        while select forUpdate salesConfirmHeaderTmp
    
        {
            select firstonly * from salesTable
    
               where salesTable.SalesId == salesConfirmHeaderTmp.SalesId;
    
               salesConfirmHeaderTmp.CustomerAccount = salesTable.CustomerAccount;
    
               salesConfirmHeaderTmp.update();
    
        }
    
        ttscommit;
    
    }
    
    }

    Thanks,

    Girish S,

  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,587 Super User 2024 Season 1 on at
    RE: Customise standard sales confirmation report

    Your code is wrong then for that customer account. Because you are giving condition like tmp.custid == sales.id means you have already the value right? If not, then your select statement is wrong. You have to check from where to pick the customer account.

    Also the select statement itself is wrong because you are selecting tmp table not sales table.

  • AXDynamics365 Profile Picture
    AXDynamics365 58 on at
    RE: Customise standard sales confirmation report

    customer account is mu custom field

    those values are come from SalesOder form , in that sales order form I used this customer Account where its data source is salesTable thats why i mapped like this "salesConfirmHeaderTmp.CustomerAccount = salesTable.CustomerAccount"

    but i dont know how i get that field value

    if you have any idea let me know

    Thanks in advance Girish S

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Customise standard sales confirmation report

    You decalred SalesTable buffer but where will you get cust account?

    Thanks,

    Girish S.

  • AXDynamics365 Profile Picture
    AXDynamics365 58 on at
    RE: Customise standard sales confirmation report

    Thanks bro it worked and report generated.

    but I didn't get my values " salesConfirmHeaderTmp.CustomerAccount = salesTable.CustomerAccount; "

    this is what i saw from an reference but i dont know why it doesnt came for me

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Customise standard sales confirmation report

    Why do you need one more select statement inside the while statement.

    While select statement is enough for your scenario. No need of select statement inside while select.

    Thanks,

    Girish S.

  • AXDynamics365 Profile Picture
    AXDynamics365 58 on at
    RE: Customise standard sales confirmation report

    class AatSalesConfirmController_Form_Handler

    {

       /// <summary>

       /// post handler for the process report

    /// method in Sales confirm dp class

       /// </summary>

       /// <param name="args"></param>

       [PostHandlerFor(classStr(SalesConfirmDP), methodStr(SalesConfirmDP, processReport))]

       public static void SalesConfirmDP_Post_processReport(XppPrePostArgs args)

       {

           SalesConfirmDP dpInstance = args.getThis() as SalesConfirmDP;

           SalesConfirmHeaderTmp salesConfirmHeaderTmp = dpInstance.getSalesConfirmHeaderTmp();

           SalesTable salesTable;

    ttsbegin;

           while select forUpdate salesConfirmHeaderTmp

           {

    select * from salesConfirmHeaderTmp

                   where salesConfirmHeaderTmp.CustomerAccount == salesTable.CustomerAccount;

               salesConfirmHeaderTmp.CustomerAccount = salesTable.CustomerAccount;

               salesConfirmHeaderTmp.update();

           }

           ttscommit;

       }

    }

    code for your reference

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Customise standard sales confirmation report

    Maybe you missed to add forUpdate keyword in the select statement.

    Thanks,

    Girish S.

  • AXDynamics365 Profile Picture
    AXDynamics365 58 on at
    RE: Customise standard sales confirmation report

    " Cannot edit a record in Show confirmation (SalesConfirmHeaderTmp). The operation cannot be completed, since the record was not selected for update. Remember TTSBEGIN/TTSCOMMIT as well as the FORUPDATE clause. "

    getting this error while generating report

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,979 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,848 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans