locked
CRM 2016: Entity>Field> Business Rule> to set a Status field based on a Date field. RRS feed

  • Question

  • Need assistance not sure how to correctly create Business Rule for a specific field condition based on a date.

    Currently I have a new Entity I created that has Start and End Dates and of course a Status Reason field.

    What i'm trying to do is create a business rule to have the "Status Reason" set to "Expired" when an End Date is past.

    I cannot figure it out how to do it correctly.

    My Fields:

    Sub Title:

    Sub Start Date:

    Sub End Date:

    Status Reason:

    Have a "Sub End Date" set to 03/01/2017 - with "Status Reason" of Active, I need the rule to set the "Status Reason" to "Expired" when the "Sub End Date" has passed.

    Any help would be appreciated. 

    I'm not a programmer, a script person, I am the administrator of our CRM application but a lot of this stuff is new to my realm of support.  So I know I have a million in 1 questions...  :-)

    Friday, February 24, 2017 6:54 PM

Answers

  • Hi Robin-

    You can do this one of two ways:

    1. You can use Workflow that runs on update of the End Date field.  Then add a Wait Condition step to your workflow, and set it to be Process -> Timeout -> Equals -> End Date.  This means the workflow will kick off, then wait until the End Date, then continue.  The next step could be the step to update the Status Reason to Expired.

    2. Create another field, that's a calculated field, and it can be labeled "Today" and then you can leave the Condition of the field blank.  For the Action, simply add a row that has = "NOW()".  Save this field and now you have a date field that will automatically update with the current date.

      Now in your Business Rule, your condition can be:
      Source: Entity
      Field: End Date
      Operator: Equals
      Type:  Field
      Value:  Today

      Now add your action to set the Status Reason to Expired.

    Good luck!


    • Edited by Pete Majer Friday, February 24, 2017 8:57 PM
    • Proposed as answer by Pete Majer Friday, February 24, 2017 8:57 PM
    • Marked as answer by RobinRK Friday, February 24, 2017 9:24 PM
    Friday, February 24, 2017 8:57 PM

All replies

  • Hi Robin-

    You can do this one of two ways:

    1. You can use Workflow that runs on update of the End Date field.  Then add a Wait Condition step to your workflow, and set it to be Process -> Timeout -> Equals -> End Date.  This means the workflow will kick off, then wait until the End Date, then continue.  The next step could be the step to update the Status Reason to Expired.

    2. Create another field, that's a calculated field, and it can be labeled "Today" and then you can leave the Condition of the field blank.  For the Action, simply add a row that has = "NOW()".  Save this field and now you have a date field that will automatically update with the current date.

      Now in your Business Rule, your condition can be:
      Source: Entity
      Field: End Date
      Operator: Equals
      Type:  Field
      Value:  Today

      Now add your action to set the Status Reason to Expired.

    Good luck!


    • Edited by Pete Majer Friday, February 24, 2017 8:57 PM
    • Proposed as answer by Pete Majer Friday, February 24, 2017 8:57 PM
    • Marked as answer by RobinRK Friday, February 24, 2017 9:24 PM
    Friday, February 24, 2017 8:57 PM
  • Thank you Pete that helped me and it worked I actually set the operator to less than or equal to "today"  that way if a sub end date is entered with a past date it would set the status to expired. 

    These are all going into my Notes Folders. So I appreciate you taking the time to respond.. I am in desperate need of advice since i'm the only one supporting/managing this application.. My role with previous company was front end level 2 support (incidents, requests, data loads etc), and our backend team or Level 3 or developers would be doing all this customizations, rules, work flows etc...  

    So i'm sure I will have plenty more questions. 

    But thank you again.  That helped me get exactly what I wanted....

    Friday, February 24, 2017 9:29 PM
  • Ok Today was a test For this... As after making my updates to the Business Rule when i'm on the record it changes the status which is great..

    But Today I find that there are a couple of records that the "status reason" field did not change to 'expired' from the View window I see it is still active... but... when I click and open that record that has a past Sub End Date (2-28-17) the status reason shows as "expired", if I save the record then the View will show expired, but if I don't save the record the view will still show the record as active... Is there something I have missed to make this update automatically?

    Wednesday, March 1, 2017 3:20 PM
  • In the top right corner of your Business Rule, what is the "Scope" set to?  You should set this to "Entity" so that it runs on the server just in case someone does a bulk edit of records (since the Bulk Edit doesn't technically open up a form, the business rule won't run).

    The other thought is that this is old data.  Business Rules will only fire when values are updated or the form is opened.  So these could be records that were there prior to your business rule and that you need to write a cleanup script to get their value set initially.

    Wednesday, March 1, 2017 3:24 PM