I can't come up with a supported way of doing this so this is the unsupported way:
In essence, this will limit the Regarding to new_keyissue and new_goal.
You'll need to fire it on the onChange event like this, NEW.Paper.limitRegardingLookup.
if (typeof (NEW) == "undefined")
{ NEW = {}; }
NEW.Paper = {
limitRegardingLookup: function () {
var KeyIssueOTC = GetEntityTypeCode("new_keyissue");
var goalOTC = GetEntityTypeCode("new_goal");
var ObjectTypeCodeList = KeyIssueOTC + ", " + goalOTC;
var LookupTypeNames = "new_keyissue:"+ KeyIssueOTC + ":Key Issues,new_goal:" + goalOTC + ":Goal";
Xrm.Page.getControl("regardingobjectid").setFocus(true);
document.getElementById("regardingobjectid_i").setAttribute("lookuptypes", ObjectTypeCodeList);
document.getElementById("regardingobjectid_i").setAttribute("lookuptypenames", LookupTypeNames);
document.getElementById("regardingobjectid_i").setAttribute("defaulttype", KeyIssueOTC);
}
};
function GetEntityTypeCode(entityName) {
try {
var lookupService = new RemoteCommand("LookupService", "RetrieveTypeCode");
lookupService.SetParameter("entityName", entityName);
var result = lookupService.Execute();
if (result.Success && typeof result.ReturnValue == "number") {
return result.ReturnValue;
}
else {
return null;
}
}
catch (ex) {
throw ex;
}
}
No comments:
Post a Comment