Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

SalesTableType vs SalesQuotationTableType

Posted on by 1,641

Hi Experts,

I made custom workflow for Sales Order as well Sales Quotation.

In Sales Order, after Sales order workflow approved then only confirmation button enable.

The code is given below.

boolean mayConfirmationBeUpdated()
{
    boolean ok;

    ok = (!(salesTable.SalesStatus  == SalesStatus::Invoiced    ||
            salesTable.SalesStatus  == SalesStatus::Delivered   ||
            salesTable.SalesStatus  == SalesStatus::Canceled)
            && (salesTable.mcrOrderStopped == NoYes::No
                || !isConfigurationkeyEnabled(configurationKeyNum(MCRCallCenter)) && (salesTable.CreditLimitApprovalStatus == SalesCreditLimitApprovalStatus::Approved || salesTable.DiscPercent == 0)) //SFA added 23Nov20
            );

    if (ok && salesCycle)
    {
        salesPurchCycle = SalesPurchCycle::findBySalesPurchaseCycle(SalesPurchCycleAction::Confirmation, SalesPurchCycleModuleParameter::Cust, salesTable.CustAccount);

        if(salesPurchCycle)
        {
            if(!salesPurchCycle.Active)
            {
                ok = false;
            }
        }
        else
        {
            if (!SalesPurchCycle::findBySalesPurchaseCycle(SalesPurchCycleAction::Confirmation, SalesPurchCycleModuleParameter::CustParameter, '').Active)
            {
                ok = false;
            }
        }
    }

    return ok;
}

In Sales Quotation, What changes are required to get same as per Sales order means after workflow get approved then only confirmation button enable.

The standard code is given below.

boolean mayConfirmationBeUpdated()
{
    //only if workflow is approved enable send button
    //if sales quotation customer is prospect, should return false
    return (salesQuotationTable.BusRelAccount == '' && !salesQuotationTable.isTemplate() &&
                (salesQuotationTable.QuotationStatus == SalesQuotationStatus::Sent
                 && salesQuotationTable.CustAccount
                 && smmOpportunityTable::find(salesQuotationTable.OpportunityId).Status != smmOpportunityStatus::Postponed
                )
           );
}

Thanks in advance..

Regards,

Faiz

  • Verified answer
    faiz7049 Profile Picture
    faiz7049 1,641 on at
    RE: SalesTableType vs SalesQuotationTableType

    I have achived by method canConfirmationBeUpdated()

    boolean  canConfirmationBeUpdated(DocumentStatus    _documentStatus = DocumentStatus::Confirmation)
    {
    
        boolean  ok = false; //true; SFA added on 21-Feb-2021
    
        if(salesQuotationTable.QuotationApprovalStatus==SalesQuotationApprovalStatus::Approved || salesQuotationTable.DiscPercent ==0)
        {
    
            ok = true;
    
           // SFA ended on 21-Feb-2021
    
        if (_documentStatus == DocumentStatus::Confirmation)
        {
            ok = this.mayConfirmationBeUpdated();
        }
        }
        return ok;
    }
    

    Thanks,

    Faiz

  • faiz7049 Profile Picture
    faiz7049 1,641 on at
    RE: SalesTableType vs SalesQuotationTableType

    Hi André Arnaud de Calavon,

    Thanks for your input. I have been tried as per suggestion but sitll we can generate quotation even workflow not approved.

    Please help me.

    boolean mayConfirmationBeUpdated()
    {
        //only if workflow is approved enable send button
        //if sales quotation customer is prospect, should return false
        return (salesQuotationTable.BusRelAccount == '' && !salesQuotationTable.isTemplate() &&
                    (salesQuotationTable.QuotationStatus == SalesQuotationStatus::Sent
                     && salesQuotationTable.CustAccount
                     && smmOpportunityTable::find(salesQuotationTable.OpportunityId).Status != smmOpportunityStatus::Postponed
                    //added by SFA on 21-feb-2021
                       && salesQuotationTable.QuotationApprovalStatus ==SalesQuotationApprovalStatus::Approved
                    
                    )
               );
    }

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 287,989 Super User on at
    RE: SalesTableType vs SalesQuotationTableType

    Hi Faiz,

    I don't know which exact field name and enum type name you have used for the quotations, but you can try to add some coding like this:

    boolean mayConfirmationBeUpdated()
    {
        //only if workflow is approved enable send button
        //if sales quotation customer is prospect, should return false
        return (salesQuotationTable.BusRelAccount == '' && !salesQuotationTable.isTemplate() &&
                    (salesQuotationTable.QuotationStatus == SalesQuotationStatus::Sent
                     && salesQuotationTable.CustAccount
                     && smmOpportunityTable::find(salesQuotationTable.OpportunityId).Status != smmOpportunityStatus::Postponed
                     // added WF coding
                     && salesQuotationTable.WorkflowStatus == MyQuotationWFStatus::Approved
                    )
               );
    }

  • faiz7049 Profile Picture
    faiz7049 1,641 on at
    RE: SalesTableType vs SalesQuotationTableType

    Hi André Arnaud de Calavon,

    Yes status fields added to SalesTable and SalesQuotationTable. Status field update based on action  performed means Accept/Reject/Request to change.

    Problem is users can confirm quotation even workflow status not approved. But in Sales order , doing some changes in method mayConfirmationBeUpdated() of SalesTable type , user can not confirm sales order if workfluw status not approved.

    Similar I want to do it in Sales quotation.

    Thanks,

    Faiz

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 287,989 Super User on at
    RE: SalesTableType vs SalesQuotationTableType

    Hi Faiz,

    Did you add approval status fields on the SalesTable and SalesQuotation table? You need new fields to know the current workflow state and manage the status when submitting the record to the workflow and when a user approves or rejects the workflow instance.

  • faiz7049 Profile Picture
    faiz7049 1,641 on at
    RE: SalesTableType vs SalesQuotationTableType

    Please help me

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,989 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,588 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans