I have a quick view form that I added to a Contact Form that pulls data from the Account entity. On the Account entity I have a field called 'new_atriskindicator' which is an option set. I can access the field on the Account form using the following javascript and display an alert.
function atRisk() {
var obj = Xrm.Page.getAttribute("new_atriskindicator");
if (obj != null)
{
//Get OptionSet Text
if (obj.getText() != null)
{
alert("At Risk Indicator: " + obj.getText());
Xrm.Page.ui.setFormNotification("At Risk Indicator: " + obj.getText(), "WARNING", "Info1");
}
}
}
I've been unsuccessful in accessing the text of the option set field from the quick view form on the Contact form. I'm very close but and unclear as to how to access the field value text although I can see the value in the console log when I expand the second entry. In the image below my text, it's the numeric value of 500000001 that I'm trying to collect and translate to the formatted description. Although the field is on the quick view form, I want to display an alert when someone access the Contact form when my at risk indicator contains a value. If I can get this working on the Contact form, I intend to add this to the Case form as the same quick view form is displayed on the Caller field is populated.
I am on CRM version 2016 version 8.2 on-premise.
function atRisk() {
var quickViewControl = Xrm.Page.ui.quickForms.get("contactquickform").getControl("new_atriskindicator");
var field = (quickViewControl.getAttribute("new_atriskindicator"));
console.log(quickViewControl);
console.log(field);
return;
}