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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

Creating invoice proposal with selected lines from sales order in x++

(0) ShareShare
ReportReport
Posted on by 15

Greetings,

I have problem in creation of invoice proposal with certain line.

the requirement is to create invoice proposal for a certain line in sales order.

but, i faced the following problem the invoice proposal created contains all the lines from any sales order connected to the project.

here is my code:

ProjInvoiceProjId       _ProjectContractId = "ProjectContract";    //Project Contract Id for which we want to create Invoice Proposal
        ProjProposalJour        projProposalJour;           //Table which will store journal records after creating Invoice Proposal
        ProjInvoiceChoose       m_oProjInvoiceChooseNormal; //Class for creating Invoice Proposal
        ProjFormLetter          projFormLetter;             //Class for Posting Invoice Proposal
        ProjTable               projTable;

        changecompany("Company")
        {
            ttsBegin;


            projTable = projTable::find("ProjectID");
            //Creation of Invoice Proposal
            m_oProjInvoiceChooseNormal = ProjInvoiceChoose::PSANew_InvoiceChoose(_ProjectContractId,projTable.ProjId,dateNull(),maxDate(),true, SalesUpdate::All);
            m_oProjInvoiceChooseNormal.parmQuerySalesLine(true);
            m_oProjInvoiceChooseNormal.parmQueryOnAccTrans(false);
            m_oProjInvoiceChooseNormal.parmQueryRetentionTrans(false);
            m_oProjInvoiceChooseNormal.parmQueryRevenueTrans(false);
            m_oProjInvoiceChooseNormal.parmQuerySubscriptionTrans(false);
            m_oProjInvoiceChooseNormal.parmQueryAdvanceTrans(false);
            m_oProjInvoiceChooseNormal.parmQueryCostTrans(false);
            m_oProjInvoiceChooseNormal.parmQueryEmplTrans(false);
            m_oProjInvoiceChooseNormal.run();

            while select forUpdate projProposalJour where projProposalJour.ProjInvoiceProjId == projTable.ProjInvoiceProjId
            {
                //For approving Invoice proposals
                projProposalJour.LineProperty = ProjLinePropertyCode::Approved;
                projProposalJour.update();
                //For Posting Invoice Proposals
                projFormLetter = ProjFormLetter::construct(DocumentStatus::ProjectInvoice);
                projFormLetter.createParmLine(projProposalJour);
                projFormLetter.run();
                //To get latest record
                projProposalJour = projProposalJour::find(projProposalJour.ProposalId);

                info(strFmt("Invoice ProposalId: %1 \t InvoiceId: %2",projProposalJour.ProposalId,projProposalJour.ProjInvoiceId));

            }

            ttsCommit;
        }

Really appreciate any assistance greatly. 

thanks.

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    305,948 Super User 2026 Season 1 on at

    Hi Nasr,

    Your coding is only indicating if sales orders should be included; not which exact sales order lines. On the standard dialog, you can make selections. This will create a query object which will be used in the process. Without selection, it will loop all order lines.

  • mehmetyunus27 Profile Picture
    57 on at

    Hi,

    Could you use one of these parameters also?

    - m_oProjInvoiceChooseNormal.parmTransIdList or

    - m_oProjInvoiceChooseNormal.parmTransIdContainer

    This can enable you to select relative SalesLine (SalesLine.ProjTransId).

  • Nasr_Mohamed Profile Picture
    15 on at

    Hi Andre,

    you are right my coding that i showed here is as far as i get.

    my code gets all salelines and i couldny find any method to pass as salesline as a parameter.

    if you have any idea how to achieve that will be greatly appreciated.

    Thanks,

  • Nasr_Mohamed Profile Picture
    15 on at

    hi Mehmet,

    i will try it.

    Thanks for your help

  • Nasr_Mohamed Profile Picture
    15 on at

    hi mehmet,

    I tiried using projTransId but it didnt work it created a propsal with all sales order here is my code:

    container               TransLine = [ProjTransType::Item,"SalesLine.ProjTransId"];

    m_oProjInvoiceChooseNormal.parmTransIdContainer(TransLine);

    do you have any suggestion?

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

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

#1
Subra Profile Picture

Subra 500

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 462 Super User 2026 Season 1

#3
Abhilash Warrier Profile Picture

Abhilash Warrier 461 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans