0

I am creating a business rule that changes the contents of the description depending on the time of day that the email is created.

enter image description here

Ideally, I would like to specify the value of date to be today's date, as the date is constantly changing. However, I need the time (12:00pm) to stay the same.

Is there a way of doing this?

Joabdh100
  • 19
  • 1
  • 8

1 Answers1

0

You cannot set today's date with a business rule.

Instead, you can use JavaScript to compare the time part of CreatedOn with 12:00, which could be done as follows:

function onLoad() {
    var createdOn = Xrm.Page.getAttribute("createdon").getValue();
    var noon = new Date(createdOn.getTime());
    noon.setHours(12, 0, 0);

    Xrm.Page.getAttribute("description").setValue(createdOn < noon ? "Good Morning" : "It's after noon!");
}
Henrik H
  • 5,747
  • 1
  • 21
  • 33