Hello,
I understand that to get the fields in the business process flow to filter you have to do it using JS and add a custom filter to those fields. The fields are named as header_process_<fieldname>.
I have this working. BUT my problem is that if I load a Case that was created before we started using BPFs, it raises an error when trying to GetControl header_process_<fieldname>.
How do I add a check before the getcontrol to see if the field actually exists on the form?
Here is my script:
function preFilterLookup() { Xrm.Page.getControl("header_process_contractid").addPreSearch(function () {
addLookupFilter();
});
}
function addLookupFilter() {
var lookupobject = Xrm.Page.getAttribute("customerid");
var value = lookupobject.getValue();
var name = value[0].name;
var id = value[0].id;
if (id != null) {
fetchXml = "<filter type='and'><condition attribute='customerid' operator='eq' value='" + id + "' /></filter>"; Xrm.Page.getControl("header_process_contractid").addCustomFilter(fetchXml);
}
}
Also Microsoft, WHY can't these fields filter out of the box. Ridiculous that I have to use JS to add custom filter to these header fields.
*This post is locked for comments