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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Sales forum / Business rule for Date...
Sales forum

Business rule for Date field

(0) ShareShare
ReportReport
Posted on by 195

Hi, 

I want to make a business rule to an Account field called "Originating Source".

I want to make it dependent on a date field on our Account entity called "onboarding start date".

I want to make a business rule saying, that if "Onboarding start date" is this "this year", then make "originating source" a required field.

Problem is, I can only choose "If Originating Source" equals/on/less than/greater than etc.

I can not select "If Originating Source" Is this year.

How would I do this? Thanks!!

Categories:
I have the same question (0)
  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at

    Hello Azillion ,

    Sorry your question is not very clear , what I understand you need below  -

    IF "onboarding start date" EQUALS THIS YEAR

    SET originating source IS REQUIRED.

    If this is your requirement then unfortunately this is not possible using Business Rules but you can achieve this using Javascript  .

      function SetFieldRequiredOrgSource(executionContext)
      {   
          var stDate =  Xrm.Page.getAttribute("onboardingstartdate").getValue();  // Replace Field Name  
          var OnBoardingStartdt = new Date(stDate);
          var OnBoardingStartDateYr = OnBoardingStartdt.getFullYear();
    
    
          var todaydate = new Date();
          var currentYear = todaydate.getFullYear();
          if(OnBoardingStartDateYr == currentYear)
          {
              Xrm.Page.getAttribute("OriginatingSource").setRequiredLevel("required"); // Replace Field Name  
          }
          else
          {
              Xrm.Page.getAttribute("OriginatingSource").setRequiredLevel("none"); // Replace Field Name  
          }
         
      }


  • Verified answer
    LuHao Profile Picture
    40,892 on at

    Hi Azillion,

    As mentioned above, Javascript can achieve that.

    If you use a business rule, you could only set a specific time interval, you have to manually modify this time interval every year.

    IF
    Onboarding start date greater than or equal "1/1/2018, 12:00:00 AM" AND Onboarding start date less than or equal "12/31/2018, 12:00:00 AM"
    THEN
    Set Originating Source as Business Required
    ELSE
    Set Originating Source as Not Business Required
    4442.6.JPG

    Click the "+New" button to add a second condition. Rule Logic selects "AND" to set the time interval for this year.

    1715.4.JPG    0310.5.JPG

    This will meet your requirements.

    4442.6.JPG    7367.7.JPG

    Please note that the start date and end date need to be manually modified to this year, and if not modified, it will default to 2018.

    Hope this helps.

    Best Regards,

    Lu Hao

  • Azillion Profile Picture
    195 on at

    Thank you! I will go with this solution.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Sales

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans