Skip to main content

Notifications

Dynamics 365 general forum
Answered

How to check field value and then run workflow

Posted on by 2,645

I have a field on my form, lets call it "Test" and when the quote record is created the Test field defaults to Unassigned.  Now when that field gets changed from Test to any other valyue in this drop down field, I do not want an email to get sent.  However, once the Test field is changed from Unassigned to something else, I then want an email to be sent when it gets changed again.  (so not the first time, but the second time).

Example:  Create quote record, and Test = Unassigned  (no email sent)

                 Test field gets changed from Unassigned to "abc" (no email sent)

                 Test field gets changed from abc to 123 (now email should get sent)

                 Test field gets changed from 123 to 456 (email should get sent)

Hope that helps, please let me know how I can make this work.  Thank you.

  • RE: How to check field value and then run workflow

    I think, simple workflow should solve the problem here or am I missing something big.

    1) On Create  - > check for Test field contains data -> Send an email else ignore.

    2) On Update, Configure Test field on the field changes list. This will ensure that the work would trigger only whenever Test Field changes  -> check for Test field contains data  --> Sent an email else ignore.

  • Suggested answer
    Pankaj Gogoi Profile Picture
    Pankaj Gogoi 3,177 on at
    RE: How to check field value and then run workflow

    Hello,

    Is there a possibility that the field may get changed from ABC to Unassigned?

    If you have audting enabled, then I would suggest having a custom workflow and fetch the old and new values using AttributeAuditDetail

    https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/gg309735(v=crm.8)

    Best Regards,

    PG

  • Verified answer
    LeoAlt Profile Picture
    LeoAlt 16,329 on at
    RE: How to check field value and then run workflow

    Hi Partner,

    I suggest that you could create a new custom field named "counts" which is used to store the times that the option set field number of updates.

    For example, you created a number field named "Counts" on  your quote form. Then you need to add some JS code on the onchange event of your "Test" option set field.

    Add the code in "Test" onchange event.

    function calculateNumber(executionContext){
        var formContext=executionContext.getFormContext();
        var number=formContext.getAttribute("new_counts").getValue();
        formContext.getAttribute("new_counts").setValue(number 1);
    }

    Add the code in form onloading event.

    function intializeNumber(executionContext){
        var formContext=executionContext.getFormContext();
        formContext.getAttribute("new_counts").setValue(0);
    }

    When we loading the quote form, the "Counts" is 0, and if we update the "Test" field, the counts changed.

    pastedimage1601520804894v1.png

    pastedimage1601520818570v2.png

    pastedimage1601520835908v3.png

    So you could use this "Counts" field as a condition in your workflow.

    Best Regards,

    Leo

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,524 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,493 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans