Compare date fields with actual dates or with each other in Business Rules

Last post 07-02-2008, 2:33 PM by gsherman. 3 replies.
Sort Posts: Previous Next
  •  12-13-2007, 12:26 PM 10806

    Compare date fields with actual dates or with each other in Business Rules

    Does anyone know if it's possible to compare date/time columns with system dates (like Today), or with each other in Business Rules?  And can I use functions of any kind (Such as DateAdd) to change the date being compared, or to get just the date portion (without the time)?  My situtation is that I want a business rule to only apply when two date/time columns in the case table are on the same day (regardless of the time).  My fear is I'll have to resort to CB code to achieve the insert of the time_bomb, but before I do I thought I'd ask the Dovetail/Clarify universe.
    Dave McFarren
    Lionbridge Technologies, Inc.
  •  12-13-2007, 4:00 PM 10812 in reply to 10806

    Re: Compare date fields with actual dates or with each other in Business Rules

    I'm pretty sure you can use CURRENT DATE-TIME or CURRENT DATE/TIME as properties, so you could write a condition such as:

    [CASE_X_DATE] < [CURRENT DATE-TIME]

    which would resolve to

    12/12/2007 10:11:12 AM  <  12/13/2007 11:22:34 AM

    But those properties would be date and time. This works great if using ">" or "<"  operators, but not very well if you're using an "=" operator, as that evaluation would have to happen at the exact millisecond for the condition to be true.

    I don't think you can do apply any functions on conditions, such as:

    Format([CASE_X_DATE],'dd/mm/yy')  =  Format([CURRENT DATE-TIME],'dd/mm/yy')

    This would require a change to RuleManager. I could check with our dev team and see what might be involved in making something like that possible.

    Are you using the Clarify Rulemanager or the Dovetail RuleManager?


    Another thought: Not sure if this is possible for your situation, but what about changing the rule around a bit so that that date is when the action fires, instead of making the date part of the condition? Create a custom rule calendar that is the path to your custom field. Then your rule action would say something like:

    start action 0 minutes from Case_x_date using Elapsed Time.

     


    Another thought: Do you care about the time portion of those 2 date columns? If not, set the time to be midnight for each of those columns when you insert/update that data.

    Then, your business rule could do an equals comparison:

    [CASE_X_DATE1] = [CASE_X_DATE2]


    Interesting problem. I'll keep thinking about it and will post here if I come up with any other ideas.

    -Gary 


    ---
    Gary Sherman
    gary@dovetailsoftware.com
    Filed under: ,
  •  07-02-2008, 11:08 AM 11344 in reply to 10812

    Re: Compare date fields with actual dates or with each other in Business Rules

    Gary,

    You mention creating a custom rule calendar.  Is there any documentation on how would you go about doing this?  We set a due date on a custom object and would like to fire a rule 24 hours before that time.


    Gary Storey
  •  07-02-2008, 2:33 PM 11346 in reply to 11344

    Re: Compare date fields with actual dates or with each other in Business Rules

    I believe the Clarify business rule manager docs have some examples, but here's how:

    1. Create a custom user-defined event creation time.
    2. Add this event creation time to the business rule action page

     

    1. Create a custom user-defined event creation time.

    In this example, I'm using the site_time column on a case:

    OBJECT  TYPE="prop_name", NAME=case_site_time
     UNIQUE_FIELD = obj_type , prop_name
      FIELDS
       obj_type=0;
       prop_name ="@USERTIME150";
       path_name ="site_time";
       val_type=609;
       max_len=30;
       extra_info ="";
       subtype=0;
      END_FIELDS
      RELATIONS
      END_RELATIONS
    END_OBJECT  NAME=case_site_time

    Of course, the path_name could include relations, such as:

    case_reporter2site:site2primary_account:x_some_date_column

     

    2. Add this event creation time to the business rule action page

    In dovetailAdmin, modify $dovetailAdmin/pages\biz_rule/inc_lists.asp

    Specifically, modify the DdlActionFrom() function, adding a new value, such as:

    out += '<option value="150" object="CASE">site time</option>' ;

    Log out & back in to dovetailAdmin.

    If you need to do this within the Clarify Client - refer to the Clarify docs on how to do a similar customization for the event creation popup (MBT_37) on form 474.

    3. Test

    Create a new business rule, and you should be able to now set it up to fire X hours before "site time".

    It's also helpful to set Rulemanager logging to a DEBUG level when testing business rule customizations such as this.

    Hope this helps.

    -Gary


    ---
    Gary Sherman
    gary@dovetailsoftware.com
View as RSS news feed in XML