Monday, 21 December 2015

How to Create Sales Quotation through X++ code in Ax 2012

static void CreateSalesQuotation(Args _args)
{
    AxSalesQuotationTable       axSalesQuotationTable;
    AxSalesQuotationLine        axSalesQuotationLine ;
    SalesQuotationTable         salesQuotationTable;
    SalesQuotationLine          salesQuotationLine;
    CustTable                   custTable;
    InventTable                 inventTable;
    SalesQty                    salesQty;
    SalesPrice                  salesPrice;
    SalesLineDisc               salesLineDisc;
    SalesLinePercent            salesLinePercent;
    container                   conItems = ["ItemA","Dell","HP"];
    int                         i =0;
    InventDim                   inventDim;
    SalesQuotationEditLinesForm salesQuotationEditLinesForm;
    ParmId                      parmId;
    SalesQuotationUpdate        salesQuotationUpdate;
    ;

    salesQty                    = 10;
    SalesPrice                  = 100;
    salesLineDisc               = 1;
    salesLinePercent            = 1;
    axSalesQuotationTable =  new AxSalesQuotationTable();
    axSalesQuotationTable.parmCustAccount('Jaga');
    axSalesQuotationTable.parmCurrencyCode('USD');
    axSalesQuotationTable.save();

    for(i = 1; i<= conLen(conItems); i++)
    {
        axSalesQuotationLine =  new AxSalesQuotationLine();//::construct(smmQuotationLine);

        axSalesQuotationLine.axSalesQuotationTable(axSalesQuotationTable);

        axSalesQuotationLine.parmQuotationId(axSalesQuotationTable.parmQuotationId());
        axSalesQuotationLine.axSalesQuotationTable(axSalesQuotationTable);
        axSalesQuotationLine.parmItemId(conPeek(conItems,i));

        axSalesQuotationLine.parmSalesQty(salesQty);
        axSalesQuotationLine.parmSalesPrice(SalesPrice);
        axSalesQuotationLine.parmLineDisc(SalesLineDisc);
        axSalesQuotationLine.parmLinePercent(SalesLinePercent);
        inventDim.InventSiteId      = "1";
        inventDim.InventLocationId  = "11";


        axSalesQuotationLine.parmInventDimId('002504');
        axSalesQuotationLine.parmcurrencyCode('USD');
        axSalesQuotationLine.save();
    }

    //Quotation status -- sent
    if(!axSalesQuotationTable.salesQuotationTable()) return;
    salesQuotationEditLinesForm =
    SalesQuotationEditLinesForm::construct(DocumentStatus::Quotation); //DocumentStatus
    parmId                      = salesQuotationEditLinesForm.parmId();


    salesQuotationEditLinesForm.initParmSalesQuotationTable(axSalesQuotationTable.salesQuotationTable());

    salesQuotationEditLinesForm.parmId(parmId);
    salesQuotationEditLinesForm.parmTransDate(systemdateget());

    salesQuotationEditLinesForm.prePromptInit();

    salesQuotationEditLinesForm.initParameters(NoYes::No, //printFormletter,
                                               NoYes::No,
//transferHours2Forecast,
                                               NoYes::No,
//transferExpenses2Forecast,
                                               NoYes::No,
//transferFees2Forecast,
                                               NoYes::No,
//transferItems2Forecast,
                                               'Competency',
//reasonCode,
                                               NoYes::No);
//usePrintManagement)
    salesQuotationEditLinesForm.run();

    /// Quotation status -- Confirmation
    if(!axSalesQuotationTable.salesQuotationTable())
        return;
    salesQuotationEditLinesForm =
    SalesQuotationEditLinesForm::construct(DocumentStatus::Confirmation); //DocumentStatus
    //Quotation o Confirm
    parmId                      = salesQuotationEditLinesForm.parmId();


    salesQuotationEditLinesForm.initParmSalesQuotationTable(axSalesQuotationTable.salesQuotationTable());

    salesQuotationEditLinesForm.parmId(parmId);
    salesQuotationEditLinesForm.parmTransDate(systemdateget());

    salesQuotationEditLinesForm.prePromptInit();

    salesQuotationEditLinesForm.initParameters(NoYes::No, //printFormletter,
                                               NoYes::No,
//transferHours2Forecast,
                                               NoYes::No,
//transferExpenses2Forecast,
                                               NoYes::No,
//transferFees2Forecast,
                                               NoYes::No,
//transferItems2Forecast,
                                               'Competency',
//reasonCode,
                                               NoYes::No);
//usePrintManagement)
    salesQuotationEditLinesForm.run();

}

2 comments:

  1. Worked like a charm - thanks!

    ReplyDelete
  2. Workday HCM Certification Training
    Gain expertise in Workday HCM modules including Core HR, Payroll, and Reporting. Learn through practical sessions designed to help you become Workday certified and job-ready.

    ReplyDelete