CRM 2013 customizer/developer here. I'm new to JavaScript and I need some help on the query I can use in an OnLoad event in CRM 2013.
On the 'Appointments' entity I need to set the value of a custom field (option set) based on entity type of it's related parent record (which is 'regardingobjectid').
Example;
-If 'regardingobjectid' Entity type = 'Account' then set value of "custom field" to "x",
-If 'regardingobjectid' Entity type = 'Contact' then set value of "custom field" to "y".
The custom field is an option set with 3 possible values (x,y,z) so if its possible to hide value "z" when 'regardingobjectid' Entity type = 'Contact' that would be awesome. Any help would be super appreciated.
Add new function to OnLoad
of Appointment
entity.
function onLoadOfAppointment() {
if (Xrm.Page.ui.getFormType() == 2) {
var regardingObject = Xrm.Page.getAttribute("regardingobjectid");
if (regardingObject != null && regardingObject.getValue() != null)
{
var entityType = regardingObject.getValue()[0].entityType;
if (entityType == "account")
{
//Add account logic here
}
else if (entityType == "contact")
{
//Add contact logic here
}
}
}
}
To Hide show OptionSet
values. Follow below urls:
dynamically-change-option-set-values-in-crm