Skip to main content

Notifications

Announcements

No record found.

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.

  • Nasr_Mohamed Profile Picture
    15 on at
    RE: Creating invoice proposal with selected lines from sales order in x++

    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?

  • Nasr_Mohamed Profile Picture
    15 on at
    RE: Creating invoice proposal with selected lines from sales order in x++

    hi Mehmet,

    i will try it.

    Thanks for your help

  • Nasr_Mohamed Profile Picture
    15 on at
    RE: Creating invoice proposal with selected lines from sales order in x++

    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,

  • mehmetyunus27 Profile Picture
    57 on at
    RE: Creating invoice proposal with selected lines from sales order in x++

    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).

  • André Arnaud de Calavon Profile Picture
    294,349 Super User 2025 Season 1 on at
    RE: Creating invoice proposal with selected lines from sales order in x++

    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.

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,349 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,029 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans