Hi there!
This looked quite stupid, but I've wasted enough time already.
I have a lookup to a custom entity called "contract type" in the contract. The business requirement is that a customer can only have one active contract per contract type. So we want to filter the contract type lookup, so the only contracts that appear are the ones that don't have an active contract for that customer.
It is very easy to find the contract types which are related to active contracts and belong to that customer. Here is the fetchXml:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
<entity name="new_contracttype">
<attribute name="new_contracttypeid" />
<attribute name="new_name" />
<attribute name="createdon" />
<order attribute="new_name" descending="false" />
<filter type="and">
<condition attribute="statecode" operator="eq" value="0" />
</filter>
<link-entity name="contract" from="new_contracttypeid" to="new_contracttypeid" alias="aa">
<filter type="and">
<condition attribute="customerid" operator="eq" uiname="org1" uitype="account" value="{BF8ACA55-35ED-E111-9CB5-00155D8283A8}" />
<condition attribute="statecode" operator="eq" value="2" />
</filter>
</link-entity>
</entity>
</fetch>
But I just need the opposite, the contract types that DON'T have an active contract and are from that customer. Wouldn't it be as easy as to change the last filter type for something like "and not"? Or am I very far away and need a very fancy query. Wasn't able to find the available filter types anywhere.
Thank you!