fetchxml linked-entity with lookup filter

Hello, In this article i will share with you how to add a lookup filter to a linked entity with Fetchxml

In the serviceappointment entity ,  i added  a lookup  field “new_contract”  to diplay the list of contract,
 so i want to display the list of contract of the selected account.

i create a fetchxml filter and i added it to javascript function :

function preFilterLookup() {
Xrm.Page.getControl("new_contrat").addPreSearch(function () {

function getlookupCustomer()
var lookupObject = Xrm.Page.getAttribute("customers");

if (lookupObject != null) {

var lookUpObjectValue = lookupObject.getValue();

if ((lookUpObjectValue != null)) {

var lookuptextvalue = lookUpObjectValue[0].id;
return lookuptextvalue;

function addLookupFilter() {
var customer = getlookupCustomer();

if (customer != null) {

fetchXml = ""
+ " "
+ "";

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s