CRM 2013 - JavaScript to determine the type of parent in applications (account or contact)

CRM 2013 configurator / developer. I am new to JavaScript and I need help with a request that I can use in the OnLoad event in CRM 2013.

In the "Destination" entity, I need to set the value of the custom field (set of options) based on the entity type of the associated parent record (which is "aboutobjectid").

Example;

-If 'aboutobjectid' Entity Type = 'Account' then sets the value of the “custom field” to “x”,

-If 'aboutobjectid' Entity type = 'Contact', then set the value of the "custom field" to "y".

A custom field is an option set with three possible values ​​(x, y, z), so if it can be hidden by the value "z" when "aboutobjectid" Entity Type = "Contact", it would be awesome. Any help would be greatly appreciated.

+4
source share
1 answer

Add a new function to the OnLoadobject Appointment.

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
        }
    }
}
}

Hide readings OptionSet. Follow below url:

dynamically-change-option-set-values-in-crm

Add a new selection using Javascript

Xrm.Page.ui control (client link)

+5
source

All Articles