This worked for me in version 9.0
function onLoadViewRelationshipOwner(context) {
debugger;
var formContext = GetFormContext(context);
var customertypecode = GetItemValue(formContext, "customertypecode");
var statecode = GetOptionValue(formContext, "statecode");
var gridContext = formContext.getControl("OWNER_BY_LOCATION_SUBGRID");
var ActiveRelationshipOwner = {};
gridContext.addOnLoad(setView);
function setView() {
debugger;
if (customertypecode == 923760006) {
// Is Active
if (statecode != 1) {
ActiveRelationshipOwner = {
entityType: 1039, // SavedQuery
id: "{FAFDDC37-5FE8-459E-B434-CC80227289CA}",
name: "Active Relationship Owners"
}
if (gridContext != null) {
// Set the view using ContactsIFollow
debugger;
gridContext.getViewSelector().setCurrentView(ActiveRelationshipOwner);
gridContext.removeOnLoad(setView);
}
}
// Is Inactive
else {
ActiveRelationshipOwner = {
entityType: 1039, // SavedQuery
id: "{6ACD9FA3-EAF6-43A2-8B95-D4345C62E217}",
name: "Inactive Relationship Owners"
}
if (gridContext != null) {
// Set the view using ContactsIFollow
debugger;
gridContext.getViewSelector().setCurrentView(ActiveRelationshipOwner);
gridContext.removeOnLoad(setView);
}
}
}
}
try {
gridContext.refresh();
} catch (e) {
}
}
I had to create a try, catch to refresh grid