I have a very basic question: can a date value be set to Now() in a business rule? Say I have a model-driven app with a status field that displays an option set. When a business rule is triggered by an event like the value selected for status = closed. I want the close date to be set to Now() and displayed immediately in the client. I see how I can perform this using a calculated field but I'm wondering if the same is possible via a business rule so the change is immediately displayed to the user without first having to save the entity (as would be necessary if relying on the calculated field). Am I missing something obvious?
Thanks in advance,
Dan
I agree. PowerApps have too many examples like this.
You need to use JScript to change the field value.
function ChangeDateToNow(){
Xrm.Page.getAttribute("new_todaydate").setValue(Date.now());
}
See both links below which might be helpfull:
Set Date as today using business roles - Microsoft Dynamics CRM Forum Community Forum
Business rule - use current date ! - Microsoft Dynamics CRM Forum Community Forum
As a workaround, you can creat a calculate column with the function Now(), and set the date you want with this value
That is NOT a good option. The validation or rule must be done in the form, like normal form technologies. The fact that variables can't be used in Business Rules after YEARS of asking, it clearly shows how little Microsoft cares about this product.
A pretty decent workaround is to use Power Automate to conditionally set the Date field using utcNow()
That's a lot of unnecessary negativity and blaspheme right there.
😞
Again, another example of an unfinished and polished product. Why having business rules, if the user can't even setup a date or calculated date... For Christ's sake, we could do that with Infopath in 2003.
Hi Dan,
I don't think this is possible unfortunately.
In the business rule editor, we can set a static date or enter a formula. If we choose the formula option, there isn't a 'Now()' option that would enable us to enter the current date.
Perhaps someone else here might know of a workaround, or to advise further.
No, sorry. I meant a Business Rule. Such as you define for a model driven app: https://docs.microsoft.com/en-us/powerapps/maker/model-driven-apps/create-business-rules-recommendations-apply-logic-form
Thanks,
Dan
WarrenBelz
223
Most Valuable Professional
MS.Ragavendar
108
stampcoin
80