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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / Control workflow appro...
Finance forum

Control workflow approval based on field value

(0) ShareShare
ReportReport
Posted on by 56

We have a requirement, in which our client has a form with multiple workflow approval steps. 

What we need- on the second step, the field needs to be mandatory for the approver to fill, before he can approve the record.
What we have done - on the second step, the field becomes mandatory meaning the user operations like save are halted unless the mandatory field is filled.

Problem:  The workflow approval is independent of the fact that the field is mandatory. So even if that mandatory field is empty, the user can approve the record and proceed with the next step in the workflow. 

Can we throw an error when the user tries to approve the record if the field is empty? 

Any suggestions for the same would be really helpful. 

  • Sohaib Cheema Profile Picture
    49,668 Super User 2026 Season 2 on at

    workflow approval happens using workflow event handler class. each workflow has its own class. in that class, you would find the code of approval. you can manage any validations there, before record is approved.

  • Ludwig Reinhard Profile Picture
    Microsoft Employee on at

    Hi,

    What 'field' is that? A standard one or one that you created?

    Do I understand it correctly that somebody has to fill this field during the second workflow step?

    Best regards,

    Ludwig

  • Tazeen Zaidi Profile Picture
    56 on at

    The field, as well as the workflow, is a custom one.

    Exactly! Yes the second step approver (for example - a finance team member), needs to enter some value in the field and only then approve the record.

  • Tazeen Zaidi Profile Picture
    56 on at

    The workflow is a custom one, so the event handlers for the approval update the workflow status of the form.

    In case we put the validation on the event handler, would the approver be restricted from approving? or would the thrown error reflect in the workflow history?

  • MATTGUO Profile Picture
    22,353 Moderator on at

    Hi Tazeen,

    You can add a condition on second step to check the field is filled in.

    7713.png

  • Tazeen Zaidi Profile Picture
    56 on at

    Hi Maatguo,

    Thank you for your assistance, and reply.  

    I tried your suggestion - what happens is, this condition defines whether the step is created or not. Incase our case when the user does not fill the mandatory field and approves in that step, the condition is evaluated to false so the next work item creation is skipped, resulting in the workflow completion.

    We need to refrain the user from approving in case the mandatory field is not filled.

    Any suggestions would be really helpful.

  • Suggested answer
    Ludwig Reinhard Profile Picture
    Microsoft Employee on at

    Hi Tazeen,

    Right, the conditions check whether it is fulfilled when you run the workflow. You should actually not be able to make a change in between, that is at the time the workflow runs. If you want to realize this in D365FO then you possibly need two workflows. An alternative is MS Flow where you have greater flexibility in designing and running workflows.

    Best regards,

    Ludwig

  • Verified answer
    Tazeen Zaidi Profile Picture
    56 on at

    The solution :

    We created a pre-event handler of the run method of the base class - WorkflowWorkItemActionManager

    And validated the workflow type and validated the required field.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans