I want to know any javascript function to capture datetime field and populate to another datetime field
Very similar to capture text field and populating to another text field
*This post is locked for comments
Thanks Rajkumar
Hi Sandy,
You to get the DateTime and set it to another field.
function GetSetDateTime() { debugger; var birthday =Xrm.Page.data.entity.attributes.get('new_birthcertificatedate').getValue(); Xrm.Page.getAttribute('new_birthday').setValue(birthday); }
For more date function and common js, please visit dynamicspeople.wordpress.com/.../common-javascript-functions
Thanks
Abhishek Bhansali
In Rajkumar's example, it should be:
if (Date1 != null && Date1 != 'undefined') {
// Example for set value
function SetDate(fieldname) {
var setdate = fieldname
Xrm.Page.getAttribute(fieldname).setValue(setdate )
}
// example GetDate("createdon");
function GetDate(fieldname) {
return Xrm.Page.data.entity.attributes.get(fieldname).getValue();
}
Hi Sandy,
Consider using Calculated field or Business Rule, to achieve this.
otherwise try this:
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.
Try this:
function onDateFieldAChange() {
if (Xrm.Page.getAttribute('new_myDateFieldA').getValue() != null) {
Xrm.Page.getAttribute('new_myDateFieldB').setValue(Xrm.Page.getAttribute('new_myDateFieldA').getValue());
}
}
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156