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, ...
Answered

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

(0) ShareShare
ReportReport
Posted on by 202

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.

I have the same question (0)
  • Verified answer
    huijij Profile Picture
    19,811 on at

    Hi Chaidir,

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

  • Chaidir Ali Assegaf Profile Picture
    202 on at

    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
    Community Member Profile Picture
    on at

    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

  • Chaidir Ali Assegaf Profile Picture
    202 on at

    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

  • Community Member Profile Picture
    on at

    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

  • Chaidir Ali Assegaf Profile Picture
    202 on at

    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

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
Martin Dráb Profile Picture

Martin Dráb 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans