Hello - I am attempting to concatenate a patient's full name in a custom entity. Since you cannot combine fields natively in a custom entity as is available with Contacts, I'll need to pull from 3 fields (last, first, middle) and set the value in the "full name" field.
I am attempting to use the following script onSave:
**Please note that when this entity was created, the default entity field was set (for some reason) as new_lastname. The requirement is that the default field/primary field for lookups is actually full name. So that is why in the script below, the "lastname" and "patientname" are swapped.**
function concatenate_name()
{
var PatientName = "";
PatientName = Xrm.Page.getAttribute("new_lastname").getValue();
var LastName = "";
LastName = Xrm.Page.getAttribute("new_patientname").getValue();
var FirstName = "";
FirstName = Xrm.Page.getAttribute("new_firstname").getValue();
var MiddleName = "";
MiddleName = Xrm.Page.getAttribute("new_middlename").getValue();
Xrm.Page.getAttribute("new_lastname").setValue(LastName + FirstName + MiddleName);
Xrm.Page.getAttribute("new_lastname").setSubmitMode("always");
}
I am not receiving a script error when attempting to save this but the system is alerting me that the "Patient Name" (new_lastname) is required... will the script not automatically concatenate on a required field or is the code incorrect?
Thanks!