Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

D365 Portal - How to validate fields on Workflow button

(0) ShareShare
ReportReport
Posted on by 441

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
    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
    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
    441 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
    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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
dkrishna Profile Picture

dkrishna 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans