Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / Send, Accept, and Reje...
Finance forum
Answered

Send, Accept, and Reject RFQ Case from X++

Posted on by 200

Hi Experts,

Can we Send, Accept, and Reject RFQ Case from X ?

I want to expose this functionality to custom service.

I found that the PurchRFQEditLines (the name of the form to send RFQ Case) is using PurchRFQFormLetter class to send the RFQ Case.

this is what I do to call the send function

PurchRFQCaseTable _PurchRFQCaseTable = PurchRFQCaseTable::findRecId(_request.parmRECID());
args.record(_PurchRFQCaseTable);
args.caller(this);
menuFunction = new MenuFunction(menuitemActionStr(PurchRFQFormLetterSend_Action), MenuItemType::Action);

if (menuFunction && menuFunction.checkAccessRights())
{
    menuFunction.enumTypeParameter(enumName2Id(enumStr(PurchRFQUpdateType)));
    menuFunction.enumParameter(PurchRFQUpdateType::Sent);
    menuFunction.run(args);
}

but there is no effect.

I found in the main method, there is a showDialog, which I believe is must be set to false if I want to call this from X .

but the default is true.

 switch (args.callerName())
{
    case formStr(PurchRFQAmendmentWizard):
        caller = caller as PurchRFQAmendmentWizard;
        // if the call is from the wizard, the wizard determines if the posting dialog should be shown
        showPostingDialog = caller.showPostingDialog() && parmEnum == PurchRFQUpdateType::Sent;
        break;

    case formStr(PurchRFQVendReply):
    case formStr(PurchRFQSealedVendReply):
        showPostingDialog = false;
        break;

    case classStr(PurchRFQVendorSelfInvitationBid_PSN):
        // Do not show the posting dialog when the vendor starts to bid on an RFQ
        // from the PurchRFQPublishOpenCase_PSN form.
        showPostingDialog = false;
        caller = caller as PurchRFQVendorSelfInvitationBid_PSN;
        break;

    case formStr(PurchRFQReplyTable):
        var isProcurementAgentEditing = args.parmObject() && args.parmObject().menuItemName() == menuItemActionStr(PurchRFQReplyEditBid);
        showPostingDialog = !isProcurementAgentEditing;
        sendEmail = !isProcurementAgentEditing;
        break;

    default:
        showPostingDialog = true;
}

is there any code example about how to use this class form X ?

Thank you.

  • RE: Send, Accept, and Reject RFQ Case from X++

    Hi Kamal,

    It is working fine now.

    I enclosed the process inside a transaction block, and the transaction is aborted for some reason.

    but after I removed the transaction block, it is working fine.

    Thank You.

    Regards,

    Chaidir

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Send, Accept, and Reject RFQ Case from X++

    Hi Chaidir,

    Yes, I have used these, and work fine for me.

    Can you explain more about "not working" like is there any error or you are not getting your desired outcome?

    If nothing happens on executing the code, then I would suggest you to run the same processes from the RFQ form for the same records that you are using for these code snippets and see what happens.

    Regards,

    Kamal

  • RE: Send, Accept, and Reject RFQ Case from X++

    Hi Kamal,

    I tried your code snippets but it is not working.

    Is this code tested? if it is, then there are some parameters or settings in my environment affecting the process

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Send, Accept, and Reject RFQ Case from X++

    Hi Chaidir,

    You can use the following code snippets:

    Send RFQ

    PurchRFQCaseTable purchRFQCaseTable = purchRFQCaseTable::find("000001");
    
    PurchRFQFormletterParmData formLetterParmData = PurchRFQFormletterParmData::newData(DocumentStatus::RFQ);
    formLetterParmData.parmSourceTable(purchRFQCaseTable);
    formLetterParmData.parmAllowEmptyParmTable(true);
    formLetterParmData.init();
    formLetterParmData.createData();
    
    // Creation of the form letter contract based on the output contract of FormLetterParmData.
    PurchRFQFormLetterSendContract formLetterContract = PurchRFQFormLetterSendContract::construct();
    FormLetterParmDataOutputContract outputContract = formLetterParmData.getOutputContract();
    formLetterContract.parmChooseLinesQueryPacked(outputContract.parmChooseLinesQueryPacked());
    formLetterContract.parmParmId(outputContract.parmParmId());
    formLetterContract.parmParmUpdate(outputContract.parmParmUpdate());
    formLetterContract.parmSourceTable(purchRFQCaseTable);
    
    // Execution of the form letter.
    FormletterService formLetterService = FormletterService::construct();
    formLetterService.postRequestForQuoteSend(formLetterContract));
    

    Accept

    PurchRFQTable purchRFQTable = purchRFQTable::find("000007");
    
    PurchRFQFormletterParmData formLetterParmData = PurchRFQFormletterParmData::newData(DocumentStatus::RFQAccept);
    formLetterParmData.parmSourceTable(purchRFQTable);
    formLetterParmData.init();
    formLetterParmData.createData();
    
    // Creation of the form letter contract based on the output contract of FormLetterParmData.
    PurchRFQFormLetterAcceptContract formLetterContract = PurchRFQFormLetterAcceptContract::construct();
    FormLetterParmDataOutputContract outputContract = formLetterParmData.getOutputContract();
    formLetterContract.parmChooseLinesQueryPacked(outputContract.parmChooseLinesQueryPacked());
    formLetterContract.parmParmId(outputContract.parmParmId());
    formLetterContract.parmParmUpdate(outputContract.parmParmUpdate());
    formLetterContract.parmSourceTable(purchRFQTable);
    
    // Execution of the form letter.
    FormletterService formLetterService = FormletterService::construct();
    formLetterService.postRequestForQuoteAccept(formLetterContract);
    

    Reject

    PurchRFQTable purchRFQTable = purchRFQTable::find("000007");
    
    PurchRFQFormletterParmData formLetterParmData = PurchRFQFormletterParmData::newData(DocumentStatus::RFQReject);
    formLetterParmData.parmSourceTable(purchRFQTable);
    formLetterParmData.init();
    formLetterParmData.createData();
    
    // Creation of the form letter contract based on the output contract of FormLetterParmData.
    PurchRFQFormLetterRejectContract formLetterContract = PurchRFQFormLetterRejectContract::construct();
    FormLetterParmDataOutputContract outputContract = formLetterParmData.getOutputContract();
    formLetterContract.parmChooseLinesQueryPacked(outputContract.parmChooseLinesQueryPacked());
    formLetterContract.parmParmId(outputContract.parmParmId());
    formLetterContract.parmParmUpdate(outputContract.parmParmUpdate());
    formLetterContract.parmSourceTable(purchRFQTable);
    
    // Execution of the form letter.
    FormletterService formLetterService = FormletterService::construct();
    formLetterService.postRequestForQuoteReject(formLetterContract);
    

    Regards,

    Kamal

  • RE: Send, Accept, and Reject RFQ Case from X++

    Hi Judy,

    I Cannot replicate the closeOk method in my pure X++ code, because the main method of PurchRFQFormLetter is switch-casing the caller method and checking in which form the PurchRFQFormLetter is called, as my pure X++ code is called from a class (not a form).

  • Verified answer
    huijij Profile Picture
    huijij 19,803 on at
    RE: Send, Accept, and Reject RFQ Case from X++

    Hi Chaidir,

    You may check the closeOk() method of the form PurchRFQEditLines which implemented sending logic.

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,914 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,549 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans