web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Modify Purchase Requisition workflow in D365 F&O

(0) ShareShare
ReportReport
Posted on by 758

Hi Everyone,

I am using Purchase Requisition workflow which has been designed as shown in below image.

However, now my client has requirement that until and unless created RFQ doesn't have its Status High as Accepted, the User should not be able to click on Submit RFQ step of workflow as shown in 2nd image below.

I will be considering StatusHigh field of PurchRFQCaseTable.

RFQ is mentioned in Purchase Requisition line. PurchReqLine table's PurchRFQCaseId field.

In one Purchase Requisition there will be only one line.

If there is an alternative solution then do suggest it. I just don't want to allow user to Submit RFQ step until and unless the RFQ has not been accepted.

How this requirement can be achieved? Do I need to modify any classes or Table method for this? Or it can be handled through Workflow design?

Please suggest solution on same. I have never designed any workflow before. The current workflow has been configured by functional consultant.

PR_5F00_Workflow.png

PR02.png

I have the same question (0)
  • Verified answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at
    RE: Modify Purchase Requisition workflow in D365 F&O

    Hi Rhushikesh,

    You can try with a CoC on the canSubmit method on PurchReqTable. This method is called by canSubmitToworkflow method and determines if the requisition can be submitted to workflow. Here you can include the logic to check for the StstusHigh field and return true/false (as per your requirement).

    I don't think you need to alter the workflow configuration for this.

  • Rhushikesh R Profile Picture
    758 on at
    RE: Modify Purchase Requisition workflow in D365 F&O

    Thanks Gunjan, it seems to be easier than what I imagined. I will try and update that.

    One question, what is the difference between 'canSubmit' and 'canSubmitWorkflow' methods?

  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at
    RE: Modify Purchase Requisition workflow in D365 F&O

    canSubmitToWorkflow is the method that you use to determine if the workflow can be submitted. It can be overriden in custom tables

    pastedimage1602175975761v1.png

    canSubmit is a custom method on PurchReqTable that is being called from canSubmit method. This method is returning a boolean value and hence I suggested doing a CoC on this one.

  • Rhushikesh R Profile Picture
    758 on at
    RE: Modify Purchase Requisition workflow in D365 F&O

    Hi Gunjan, somehow my CoC doesn't work. Even I tried to put the breakpoint but it never got hit.

    Am I writing any wrong logic? Would you please correct it?

    My code looks like below,

    6663.Code.png

  • Gunjan Bhattachayya Profile Picture
    35,423 on at
    RE: Modify Purchase Requisition workflow in D365 F&O

    Hi Rhushikesh,

    The select statement could be improved, but it should hit this breakpoint. Could you try building your model to check if it hits the breakpoint?

    Also, have you configured and activated the purchase requisition workflow?

  • Rhushikesh R Profile Picture
    758 on at
    RE: Modify Purchase Requisition workflow in D365 F&O

    Yes Gunjan, the workflow is active. Even I put info in CoC class. But that also not getting popped up on screen.

    PRWF.png

  • Gunjan Bhattachayya Profile Picture
    35,423 on at
    RE: Modify Purchase Requisition workflow in D365 F&O

    Hi Rhushikesh,

    Could you please put paste your code here, rather than a screenshot?

  • Rhushikesh R Profile Picture
    758 on at
    RE: Modify Purchase Requisition workflow in D365 F&O

    Here's the code Gunjan,

    [ExtensionOf(tableStr(PurchReqTable))]
    
    final class SimahPurchReqTbl_Extension
    
    {
    
        public boolean canSubmitToWorkflow(str _workflowType)
    
        {
    
            PurchReqLine purchReqLine;
    
            PurchRFQCaseTable purchRFQCaseTable;
    
            boolean ret = true;
    
            ret = next canSubmitToWorkflow(_workflowType);
    
            info("CoC called");
    
            if (_workflowType == workFlowTypeStr(PurchReqReview))
    
            {
    
                select * from purchReqLine where purchReqLine.PurchReqTable == this.RecId;
    
                if (purchReqLine.PurchRFQCaseId)
    
                {
    
                    purchRFQCaseTable = PurchRFQCaseTable::find(purchReqLine.PurchRFQCaseId);
    
                    if (purchRFQCaseTable.StatusHigh != PurchRFQStatus::Accepted)
    
                    {
    
                        warning("Cannot submit RFQ as RFQ status is not accepted.");
    
                        ret = false;
    
                    }
    
                }
    
            }
    
            return ret;
    
        }
    
    }

  • Gunjan Bhattachayya Profile Picture
    35,423 on at
    RE: Modify Purchase Requisition workflow in D365 F&O

    Hi Rhushikesh

    Let's do a quick check. I have set the return to false so that the workflow button is not enabled.

    [ExtensionOf(tableStr(PurchReqTable))]
    final class SimahPurchReqTbl_Extension
    {
        public boolean canSubmitToWorkflow(str _workflowType)
        {
            PurchReqLine purchReqLine;
            PurchRFQCaseTable purchRFQCaseTable;
            boolean ret;
    
            ret = next canSubmitToWorkflow(_workflowType);
    
            if (_workflowType == workFlowTypeStr(PurchReqReview))
            {
                select purchReqLine
                    join purchRFQCaseTable
                        where purchRFQCaseTable.rfqCaseId       == purchReqLine.PurchRFQCaseId &&
                              where purchReqLine.PurchReqTable  == this.RecId;
                select * from purchReqLine where purchReqLine.PurchReqTable == this.RecId;
                if (purchRFQCaseTable && purchRFQCaseTable.StatusHigh != PurchRFQStatus::Accepted)
                {
                    ret = false;
                }
            }
            //return ret;
            return false;
        }
    
    }

    Please check after a full build of your model and check if the workflow button is disabled. This will prove that the CoC is working.

  • Rhushikesh R Profile Picture
    758 on at
    RE: Modify Purchase Requisition workflow in D365 F&O

    Hi Gunjan,

    I tried returning false and built the model. However, workflow button is still enabled.

    I see cansubmitToWorkflow method on PurchReqTable form as well. From there also, I tried returning false. But somehow it doesn't work.

    In my case submitting user and approver user are same for testing purpose. Is it happening because of this?

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,100

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 633 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans