Hello experts,
I am going around in circles attempting to create a concatenated column derived from a date/time field.
The code I am using is as follows:
------------------------------------------------
function onChange_dov()
{
var objdate = Xrm.Page.getAttribute("rst_asset_dov").getValue();
if (objdate != null)
{
var year = objdate.toLocaleDateString('en', {year: '2-digit'});
var month = objdate.toLocaleDateString('en', {month: '2-digit'});
Xrm.Page.getAttribute("rst_asset_dov_col").setValue((month + "/" + year));
Xrm.Page.getAttribute("rst_asset_dov_col").setSubmitMode('always');
}
}
----------------------------------------------------
The error I get is telling me the setValue is null:
----------------------------------------------------
One of the scripts for this record has caused an error. For more details, download the log file.
Cannot read properties of null (reading 'setValue')
Session Id: 070e3b8e-8f6b-47a6-8c47-bedc43eed22c
Correlation Id: 35996f97-9348-4bfc-a4d0-ec1a375d99c6
Event Name: onchange
Web Resource Name: rst_asset_dov_calc
Solution Name: ActivePublisher Name: DefaultPublisherSCFMCRM
Time: Fri Feb 11 2022 09:56:50 GMT+0800 (Australian Western Standard Time)
Download Log File
OK
-------------------------------------------------------
Where I test the code and variables and output using objdate = new Date();, there is no issue, it presents 02/22 as I would expect.
Any suggestions would be greatly appreciated.
Thank you in advance,
Jayden.