Reputation: 81
At this moment I know how to use the addCustomFilter in combination with addPreSearch (and the remove variants). All this works perfectly when passing a filterXml like:
<filter type="and">
<condition attribute="name" operator="eq" value="test123" />
</filter>
But I just can't figure out how to use linked-entities in the addCustomFilter and whether it is actually possible. I've tried the following:
<link-entity name="account" from="accountid" to="parentaccountid">
<filter type="and">
<condition attribute="name" operator="eq" value="test123" />
</filter>
</link-entity>
It is still the same filter but it is now placed on the parent account of the account. With this filterXml I want to get all the accounts that have the account 'test123' as the parent account.
The problem is that the filter doesn't work in the addCustomFilter but it does return results in the AdvancedFind.
Is there a way to use linked-entities in the addCustomFilter method, if so what am I doing wrong?
Upvotes: 8
Views: 7978
Reputation: 790
addCustomFilter
method takes two parameters filter
and the entityLogicalName
. The entityLogicalName is optional and if this parameter is provided, the filter will only apply to that entity type. Otherwise it will apply to all types of entities returned.
For e.g. customer lookup control display account and contact records. If we don't provide the entityLogicalName
parameter, the filter will apply to both account and contact records and if we provide 'account' as a parameter then filter will only be applied to account records not to contact records.
So ...
If we're using another related entity (as with your example) as the filter, it is using <linked-entity
>,
.addCustomFilter()
method.BUT There is a way ..
Actually the only way is still using the MSCRM 2011 Code, that is using .addCustomView()
with its many parameters (using your own fetchXml & layoutXml).
//the only way :
setView = function(context, arg, viewId, entityName, viewDisplayName, fetchXml, layoutXml, isDefault) {
var page = context.getFormContext();
page.getControl(arg).addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, isDefault);
...
}
Upvotes: 7