web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Business Rules Issue - Date field A should = date field B

(1) ShareShare
ReportReport
Posted on by

Hi,

I create a business rule that says...

If "Field A(Date field)" contains data

Then

Set Field B(Date field) value to Field A(Date field).

The issue is Date Field B keeps adding an extra day so if Date Field A = 5/5/2015 its setting Date Field B to 5/6/2015. I do not have any other business rules in the system or custom code. Anyone know why this is happening?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    AEdwards Profile Picture
    765 on at
    RE: Business Rules Issue - Date field A should = date field B

    Hey Jonathan,

    I actually ran into this issue too, only instead of Date Field B being set to, for example, 5/6/2015, it was being set to 5/4/2015 (it subtracted a day).

    I ended up fixing mine by creating a JavaScript that basically does what the Business Rule was supposed to do.

    So like,

    function onDateFieldAChange() {

        if (Xrm.Page.getAttribute('new_myDateFieldA').getValue() != null) {

           Xrm.Page.getAttribute('new_myDateFieldB').setValue(Xrm.Page.getAttribute('new_myDateFieldA').getValue());

       }

    }

  • Suggested answer
    Mahadeo Matre Profile Picture
    17,021 on at
    RE: Business Rules Issue - Date field A should = date field B

    Hi Jonathan,

    It is look like a bug in Business rules.

    When you are setting one date attribute value from another date attribute value.. it is setting incorrectly..

    You can use simple Javascript code to set date field value..

    Here is sample code

    function SetDate2()

    {

      var Date1 =  Xrm.Page.getAttribute('new_date1').getValue();

      if(Date1 !=null || Date1 !='undefined')

      {

         Xrm.Page.getAttribute('new_date2').setValue(Date1);

      }

    }

    Call this function on your first date (field A) on change event and change new_date1 with

    Field A and new_date2 with Field B attribute name.

    save and publish your customization..

    Hope this will help..

  • Mahadeo Matre Profile Picture
    17,021 on at
    RE: Business Rules Issue - Date field A should = date field B

    Jonathan / AEdwards,

    I submitted this issue to Microsoft, please vote for this issue

    connect.microsoft.com/.../1306227

  • Community Member Profile Picture
    on at
    RE: Business Rules Issue - Date field A should = date field B

    Thank you both for the replies. I actually opened a case with Microsoft last week and this morning they confirmed this was an unknown bug. I hope they fix it soon so I do not have to apply any code.

  • Aileen Gusni Profile Picture
    44,524 on at
    RE: Business Rules Issue - Date field A should = date field B

    Jonathan, can add one more condition.

    If "Field A(Date field)" contains data AND "field B does not equal Field A

    Then..

    Set Field B(Date field) value to Field A(Date field).

    But just worry that field B never triggered.

    Just try it first.

    Thanks.

  • Suggested answer
    purwar purwar Profile Picture
    2,836 on at
    RE: Business Rules Issue - Date field A should = date field B

    Kindly check user's time zone & crm time zone. Because CRm storing date in GMT format.

    And it display date according to user's time zone.  Kindly check it.  Other log a ticket to microsoft. because it is default functionality of MS CRM.

  • mscrmba Profile Picture
    on at
    RE: Business Rules Issue - Date field A should = date field B

    As per Priyadarshi, I would assume it was much more likely a time zone/display issue rather than an out-and-out bug.  (Especially given we have 2 examples where it can be either +/- a day.)

    Are your server and client timezones in sync?  (We have come across issues importing data where dates were adjusted by 1 hour.)

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Business Rules Issue - Date field A should = date field B

    Hi Jonathan,

    Check how much time is difference between Field A and Filed B and check with User Time Zones.

  • AEdwards Profile Picture
    765 on at
    RE: Business Rules Issue - Date field A should = date field B

    Actually, regardless of your guys' statement about Time Zone, I would still mark this a bug. If I create a Business Rule that states set Date2 EQUAL to Date1, the user/ CRMs TimeZone should be independent of that, it should set the Dates equal to each other, simple as that.

    In any case, I did testing; To clarify, I created these fields, I added the time to them, so it should ALL be in my TimeZone. I'm in (GMT -05:00) EST and whenever I set the date the Business Rule sets it to the date before. Now, when I added a time component and set my Date to, for example, 5/10/2015 at 12:00p the Business Rule would set Date2 to 5/9/2015 at 8:00pm. When I set my Date to 5/15/2015 at 8:00pm the Business Rule sets the Date2 to 5/14/2015 at 8:00pm.  This tells me that the TimeZone is irrelevant.

  • Suggested answer
    Mahadeo Matre Profile Picture
    17,021 on at
    RE: Business Rules Issue - Date field A should = date field B

    In Addition to AEdwards, I also vote for Bug.. 

    If it is time zone issue, then it should behave same if you are using JavaScript to set value. 

    Here is my complete explanation 

    I Created two date attributes in custom entity

    6215.4.png

    Now Added Business rule for Date 1 field as below

    7853.2.png

    Activated Business Rule and published customization.

    Entered Date 1 value from entity form

     6215.3.png

    Now as per business Rule, I am setting value of Date 1 to Date 2, so it should be same as Date1 selected date, but not It is always one day less than selected date. 

    6215.4.png

    I disabled Business rule and added Simple JavaScript code on Date 1 attribute change 

    function SetDate2()

    {

       var Date1 =  Xrm.Page.getAttribute('new_date1').getValue();

       if(Date1 !=null || Date1 !='undefined')

       {

          Xrm.Page.getAttribute('new_date2').setValue(Date1);

       }

    }

    This JavaScript function is also doing same thing as Business rule is doing.. but when I use JavaScript value of Date 2 field is set correctly. 

    0820.5.png

    As Business Rule and JavaScript both are client side, so I don't think so It is matter of Time zone. and if it is problem with Time zone, then why behaving differently for business rule and JavaScript?

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

#3
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans