Notifications
Announcements
No record found.
Hi All,
i just need the simplest way to set a date field to be NOW when another field's value changes
i prefer if there is a way using business rules.
Your help is appreciated
Thanks
*This post is locked for comments
Hi
Business Rule does not have any operator which check if the field value has changed.
You need to use JScript to change the field value. Use this script on the OnChange event of the field.
function FieldValueChange(){ Xrm.Page.getAttribute("new_todaydate").setValue(Date.now());}
Hope that helps
Hi Alaa,
You cannot set the current date using Business Rule, there is no operator set value based on today date in CRM 2013, yes, you need a javascript.
Thanks.
Is there any way to compare date field with todays date in business rule an then set Action ?
Regards,
Kamran
You can accomplish this using the workflows rather than the 'Business Rule' option:
- Create a workflow and set which field changes it triggers on - I don't think it needs to be synchronous for your needs?
- Choose to update the record, and populate the relevant field using the options shown below to put in the process execution time.
Hi AllaMoh,
There is no way for your requirement using business rules,For this You have to write Javascript Onchange,You can see below code:
var currentDateTime = new Date();
var millis = currentDateTime.getTime() + (currentDateTime.getTimezoneOffset() * 60000);
currentDateTime.setTime(millis);
Xrm.Page.getAttribute(fielName).setValue(currentDateTime);
Try on this,may it will help you.
you can set a RT workflow that its trigger is the change of the field
the value that will be implemented is the execution date&time of the workflow
Is this issue fixed in 2015 ?
[quote user="Mithilesh Kumar"]
[/quote]
This code worked beautifully for me, though I did need to add:
Xrm.Page.getAttribute("[fieldname]").setSubmitMode("always");
In order for my form to save the value in the field I was updating (a read-only date/time field).
Agree with AlaaMoh89 this should be fixed by MS. Something simple like: when there's no datetime specified in Value, the default datetime is Now datetime.
You can simulate onChange events in your business rules or calculated fields with some creativity.
Mind that this only works if you want the datetime field to be populated based on one field changing, if you want it to run on multiple possible field changes, it wont work and I wouldnt recommend using below method, because it will create an overkill on fields.
If there is just one field however, you can copy the old field’s value to a new field (both fields should be of the same type) with a workflow on change of the old field (before change). Create a Calculated Date-Time field, which states if new value of old field does not equal the value of the new field (=change) set the datetime to Now().
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
SA-08121319-0 4
Calum MacFarlane 4
Alex Fun Wei Jie 2