Announcements
No record found.
Hi, I need to set the year from the birthdate, month and day is setting the values correctly while the year is reading it right but don't set it. why ?below is my script,thank you //==== Start OF: GetBirthdate============================================================= function GetBirthdate() { debugger; if(Xrm.Page.getAttribute("new_birthdate").getValue() != null) { var dateFieldValue= Xrm.Page.getAttribute('new_birthdate').getValue(); var year = dateFieldValue.getFullYear(); var month = dateFieldValue.getMonth()+1; var day = dateFieldValue.getDate(); //var dateOnly = new Date(year,month+1,day); Xrm.Page.getAttribute("new_birthday").setValue(day); Xrm.Page.getAttribute("new_birthmonth").setValue(month); Xrm.Page.getAttribute("new_birthyear").setValue(year); } else { Xrm.Page.getAttribute("new_birthday").setValue(null); Xrm.Page.getAttribute("new_birthmonth").setValue(null); Xrm.Page.getAttribute("new_birthyear").setValue(null); } }// end of function //==== END OF: Fill Birthday,BirthMonth and Birthyear if birthdate is filled
*This post is locked for comments
Hi,
When you say it doesn't set it - what do you mean. Do you get a null value or an error in the debug console.
Check the data type of the attribute is compatible with the year value.
Check that you have the correct attribute logical name.
no its not giving an error but the field remains empty. while day and month is filled
Hi Faith,
Try using this:
Xrm.Page.getAttribute("new_birthyear").setValue(year.toString())
Thanks,
Prateek
thanks Prateek still the same its empty
Please check your method is getting triggered or not?
Regards
Hemant
Check whether the below variable has value in the debugging mode.var year = dateFieldValue.getFullYear();
probably the field name is not new_birthyear, check the field name that should store the year part
Hi ,
I tried the following , and it works for me
var dateFieldValue = Xrm.Page.getAttribute("createdon").getValue();var year = dateFieldValue.getFullYear();Xrm.Page.getAttribute("description").setValue(year.toString());
Regards,
Vilas Magar
I assume the new_birthyear is string type and you have published all customization.
Can you point the year to month and see if the value is getting filled :
Xrm.Page.getAttribute("new_birthmonth").setValue(year.toString());
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.
Congratulations to our 2026 Super Stars!
We are thrilled to have these Champions in our Community!
These are the community rock stars!
Stay up to date on forum activity by subscribing.
JS-09031509-0 3
AS-17030037-0 2
Mark Eckert 2