RE: Set regarding activity from another field
Ok, so ... I customized the appointment view to make easier for the user to get around. We have a custom appointmenttype field which has 5 different values: Distributor, end-user, industry, event, other. Depending on the chosen value, the following things get done:
- Specific checklist gets shown/hidden (works perfectly)
- Set regarding field is filtered depending on the type (custom accounttype field in Accounts). This works except for event (= custom entity, but the lookup field shows everything so code is not working somehow) and the fact that you can no longer set a contact.
This is the code:
function setAppointmentRegardingLookup()
{
Xrm.Page.getControl("regardingobjectid").addPreSearch(addFilter);
}
function addFilter()
{
var AppointmentTypeText = Xrm.Page.getAttribute("xx_appointmenttype").getText();
if(AppointmentTypeText == "Visit - Distribution")
{
var fetchQuery = "<filter type='and'><condition attribute='xx_accounttype' operator='eq' value='960800002' /></filter>";
Xrm.Page.getControl("regardingobjectid").addCustomFilter(fetchQuery, "account");
}
else if (AppointmentTypeText == "Visit - End-User")
{
var fetchQuery = "<filter type='and'><condition attribute='xx_accounttype' operator='eq' value='960800000' /></filter>";
Xrm.Page.getControl("regardingobjectid").addCustomFilter(fetchQuery, "account");
}
else if (AppointmentTypeText == "Visit - Industry")
{
var fetchQuery = "<filter type='and'><condition attribute='xx_accounttype' operator='eq' value='960800001' /></filter>";
Xrm.Page.getControl("regardingobjectid").addCustomFilter(fetchQuery, "account");
}
else if (AppointmentTypeText == "Event")
{
var fetchQuery = "<filter type='and'><condition attribute='new_eventid' operator='not-null' /></filter>";
Xrm.Page.getControl("regardingobjectid").addCustomFilter(fetchQuery, "event");
}
}
So now, there a few solution:
- Fix the code above so the events do get filtered
- Somehow get code to set the "look-in" value in the lookup window of "Regarding" based on the appontmentType
- work the other way: Use the regarding object to set the appointmentType.
Hope this helps?