I'm trying to add my first custom JavaScript to a form field. I added this source code as a Web Resource to my custom solution:
function nmc_setSuppItemSubmissionDate() {
debugger;
var submissionStatus = Xrm.Page.getAttribute("datatel_submissionstatus").getValue();
var submissionDate = Xrm.Page.getAttribute("datatel_submissiondate").getValue();
if (submissionStatus == "Received" || submissionStatus == "Waived" || submissionStatus == "Approved") {
if submissionDate == "" {
var currentDateTime = new Date();
Xrm.Page.getAttribute("datatel_submissiondate").setValue(currentDateTime);
}
}
else {
Xrm.Page.getAttribute("datatel_submissiondate").setValue(null);
}
In the list of Web Resources, it has a Display Name of SetSupplementalSubmissionDate and a Name of nmc_setSubmissionDate.
I then went into the:
- Form Properties Events tab and added nmc_setSubmissionDate to the Form Libraries
- Field Properties Events tab of the datatel_submissionstatus field and added the library nmc_setSubmissionDate and function nmc_setSuppItemSubmissionDate
to the OnChange event
I saved and published the form. When I change the datatel_submissionstatus field in the form, I get the error:
There was an error with this field's customized event: Field: datatel_submissionstatus Event:onchange
Error:'nmc_setSuppItemSubmissionDate' is undefined.
I'm not sure what I'm doing wrong. If anyone could explain this, I would be grateful.
*This post is locked for comments
I have the same question (0)