Hi, I created below Javascript. The goal of this Javascript is to get a boolean value through the contact lookup and set a boolean on the quick create form:
// GET Lookup
function retrieveContact(executionContext) {
// Access the field on the form
var field = executionContext.getFormContext().getAttribute("msevtmgt_contactid");
// Verify it does exist on the form
if (field != null) {
// Get its field value; Returns the Lookup object
var value = field.getValue();
// To get the Id, Name and Entity Name (account/contact)
var record_id = field.getValue()[0].id;
var record_name = field.getValue()[0].name;
var record_entityName = field.getValue()[0].entityType;
}
function GetRelatedData(executionContext) {
var formContext = executionContext.getFormContext();
//
Xrm.WebApi.retrieveRecord("contact", record_id, "?$select=rbc_participant").then(
function success(result) {
if (result.rbc_participant == true)
formContext.getAttribute(rbc_participantcontact).setValue(true);
}
function error(error) {
Xrm.Navigation.openAlertDialog({
text: error.message
});
}
);
}
}
I can't seem to get it to work. I do not get an error, it does nothing. Does anybody has an idea?
Below a screenshot regarding the form. So when Contact Person contains data and on that record the Participant value == Yes, then the Participant contact? field should set to Yes. This should happen onchange of the Contact Person. So I can't use a workflow.