Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Urgent Help Required - MS Dynamics CRM Lookup filtering issue

(0) ShareShare
ReportReport
Posted on by 60

Hi All,

I am applying below code to filter my lookup control but i am facing below issue when script loading onto the form.

I am posting both the code and scenario. Please help

1)First Error

Error :  fetchXML is not defined.

code: 

function setLookupView()
{
Xrm.Page.getControl("cdemo_casetype").addPreSearch(filterCaseType);
}


function filterCaseType()
{

var _product = Xrm.Page.getAttribute("productid").getValue();

if (_product != null)
{
var _productid = _product[0].id;
var _productname = _product[0].name;
}

var fetchXML = "<fetch version=\"1.0\" output-format=\"xml-platform\" mapping=\"logical\" distinct=\"true\">" +
"<entity name=\"demo_casetype\">" +
"<attribute name=\"demo_casetypeid\" />" +
"<attribute name=\"demo_casetype\" />" +
"<attribute name=\"createdon\" />" +
"<order attribute=\"demo_casetype\" descending=\"false\" />" +
"<link-entity name=\"demo_casesubtype\" from=\"demo_casetypeid\" to=\"demo_casetypeid\" alias=\"ac\">" +
"<filter type=\"and\">" +
"<condition attribute=\"demo_productgroup\" operator=\"eq\" uiname=\""+_productname+"\" uitype=\"demo_productgroup\" value=\""+ _productid +"\" />" +
"</filter>" +
"</link-entity>" +
"</entity>" +
"</fetch>";


Xrm.Page.getControl("demo_casetype").addCustomFilter(fetchXml);

}

*This post is locked for comments

  • Iswarya Profile Picture
    Iswarya 1,345 on at
    RE: Urgent Help Required - MS Dynamics CRM Lookup filtering issue

    Hi,

    var fetchXML

    your declaring variable name as fetchXML , customFilter is fetchXml  Both should be same.(check the case )

    Xrm.Page.getControl("demo_casetype").addCustomFilter(fetchXml);

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,321 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans