web
You’re offline. This is a read only version of the page.
close
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.

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    301,148 Super User 2025 Season 2 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 449 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 422 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans