Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 82002

CRM oData Query to filter a Lookup Filed

$
0
0

Hi,

When a user selects a country from a lookup control, the other lookup control should show only the related provinces on that lookup control. (based on the selection of the parent control, the other 2nd lookup values should get changed)

I want to write a oData Query to filter values of a lookup field. when the

see the code below...

var lookupObject = Xrm.Page.getAttribute('country');


if (lookupObject != null)

{
var lookUpObjectValue = lookupObject.getValue();
if ((lookUpObjectValue != null))

{
var query = "/new_provinceSet?$select=provinceid,provincename&$filter=country eq guid'" + lookUpObjectValue[0].id + "'";
var queryResults = ExecuteQuery(query);
var value = queryResults.results[0];

//populate lookup with the values
if (value != null) {
Xrm.Page.getAttribute('province').setValue( [{id: value.provinceid, name: value.provincename, entityType: "Provinces"}]);
}
}
}


Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images