Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

D365 Portal - How to validate fields on Workflow button

Posted on by 437

Hello Everyone,

I've create a workflow button called "Decline " in partner portal form. When I click on that button a background workflow runs and it set record status to "Declined".

But before running that workflow , I need to validate a field called as "Decline Reason" and then execute the workflow. 

So , If I click on Decline button it should first ask me to fill "Decline reason"  value and then set record status to Declined!

Any solution on this please?

*This post is locked for comments

  • Suggested answer
    Nicholas Hayduk Profile Picture
    Nicholas Hayduk 2,863 on at
    RE: D365 Portal - How to validate fields on Workflow button

    As Oliver pointed out, you can create the button using JavaScript which then requires the reason, but in the end you need to click save again.

    The challenge is that the only way to save data back to Dynamics is by having the user click the save button.

    If you wanted to get really fancy, you could in theory:

    - Add the reason field to the form, but hide it using JS

    - Create a custom button in JS that pops up a modal asking for the reason

    - Once they confirm their reason, use JS to copy the reason from the modal into the hidden reason field, and then us JS to click the save button on behalf of the user.  Since you've copied the reason to a field on the form, it will get saved to Dynamics.

    Nick

  • Suggested answer
    oliver.rodrigues Profile Picture
    oliver.rodrigues 4,052 on at
    RE: D365 Portal - How to validate fields on Workflow button

    Prashant you can place a "Decline Button" via JS that shoes the "decline reason" field (also adding the necessary validation of course) and then simply save the record.. your WF in the background should do the trick

  • Prashant Wani Profile Picture
    Prashant Wani 437 on at
    RE: D365 Portal - How to validate fields on Workflow button

    Thanks for your reply Nicholas.

    Can it be achieved using any custom button to set the status and  and ask user to fill status reason?

    We have demonstrated button functionality to user for declining lead and hence they would expect to have button.

  • Suggested answer
    Nicholas Hayduk Profile Picture
    Nicholas Hayduk 2,863 on at
    RE: D365 Portal - How to validate fields on Workflow button

    Hi Prashant,

    There is no out-of-the-box way to force a use to fill out a field before clicking a workflow button.

    Instead of running a workflow to set the status, I'd have both fields (status and the reason) as fields on the form.  You can then use JavaScript and validators to only show and require the Decline Reason field when the status is set to declined.  If there is other logic happening in your workflow, it could be triggered on the status change (as opposed to have the workflow trigger the status change).

    Hope that helps.

    Nick

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans