Yosra,
Yout fetch xml here:
fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"
+ "<entity name='serviceappointment'>"
+"<attribute name='customers' />"
+"<filter type='and'>"
+"<condition attribute='regardingobjectid' operator='eq' value='" + customer + "' />"
+"</filter>"
+"<link-entity name='contract' from='contractid' to= 'new_contrat'>"
+"<filter type='and'>"
+" <condition attribute='customerid' operator='eq' value='" + customer + "' />"
+"</filter>"
+" </link-entity>"
+"</entity>"
+"</fetch>";
is not supported as xml for addCustomFilter() method.
It only supports <filter> node XML:
"<filter type='and'>"
+"<condition attribute='regardingobjectid' operator='eq' value='" + customer + "' />"
+"</filter>"
It does not support the linked entity: +"<link-entity> to put in the XML for addCustomFilter() method.
But as I know it didn't event prompt you an error, but the data is still not filtered as per expectation without any pop up message.
You can use a addCustomView() if you want to use your current fetch XML.
msdn.microsoft.com/.../gg334266.aspx
But, you need to construct your own layoutXML and you might have problem found that the grid is appearing inconsistent.
See this post:
community.dynamics.com/.../134494.aspx
Or you can use this filter if you use addCustomFilter() method, for example:
<filter type="and">
<condition attribute="customerid" operator="in">
<value>{1B0CF2DC-BE2D-E411-9451-001CC4EECDD4}</value>
</condition>
</filter>
But, it will only filter one condition, cannot to have multiple condition of linked entity (you have condition regarding to, contract, etc)
missdynamicscrm.blogspot.com/.../crm-2013-using-addcustomfilter-to-get-filtered-lookup-field-based-on-linked-entity.html
Which the ID 1B0CF2DC-BE2D-E411-9451-001CC4EECDD4}) is you get from what Guido suggested before:
And then, if you want to filter a Contract List, then you should not use:
"<entity name='serviceappointment'>"
entity name as serviceappointment, instead, you should use Contract.
Yes, you need to go Advanced Find, do the query and then you can download the XML.
Use the XML to contrsuct the addCustomView()
msdn.microsoft.com/.../gg334266.aspx
Example:
www.powerobjects.com/.../creating-custom-filtered-lookup-crm-2011
Hope this helps!
Thanks.