Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

FetchXml Querry is not working.

Posted on by Microsoft Employee

Hii everyone.

I have an MyShoppings is an Entity and I have written a query in which I am fetching data with shopping name = "Brand Factory".

The code is:-

function ShopOnLoad()
{

alert('Function approached");

var shopFetchXML = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'> "+
" <entity name='new_myshopping'> "+
" <attribute name='new_myshoppingid'/>"+
" <attribute name='new_shoppingname'/>"+

" <attribute name='createdon'/>"+
" <order attribute='new_shoppingname' descending='false'/>"+
" <filter type='and'>"+
" <condition attribute='new_shoppingname' operator='eq' value='Brand Factory'/>"+
" </filter>"+
" </entity>"+
"</fetch>" ;

alert("XMLFetch Query Executed");

var shopRecords = XrmServiceToolkit.Soap.Fetch(shopFetchXML);

alert("Multiple data fetched");

//if(shopRecords.length > 0)
//{

alert("If Condition approached");

alert(shopRecords[0].attributes.new_shoppingname.value);

}//

alert("Finished");

}

The error I got that ShoponLoad is not defined at eval.
I have defined  in form Load of an MyShopping Entity.

For this I have also applied Jquery,Json,XRMToolkit Web Resources  I have added.

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: FetchXml Querry is not working.

    Thanks Iswarya.

  • Verified answer
    Iswarya Profile Picture
    Iswarya 1,345 on at
    RE: FetchXml Querry is not working.

    Hi,

    now try i made changes in your code

    function ShopOnLoad()
    {

        alert("Function approached");

        var shopFetchXML = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'> "+
        " <entity name='new_myshopping'> "+
        " <attribute name='new_myshoppingid'/>"+
        " <attribute name='new_shoppingname'/>"+

        " <attribute name='createdon'/>"+
        " <order attribute='new_shoppingname' descending='false'/>"+
        " <filter type='and'>"+
        " <condition attribute='new_shoppingname' operator='eq' value='Brand Factory'/>"+
        " </filter>"+
        " </entity>"+
        "</fetch>" ;

        alert("XMLFetch Query Executed");

        var shopRecords = XrmServiceToolkit.Soap.Fetch(shopFetchXML);

        alert("Multiple data fetched");

        //if(shopRecords.length > 0)
        //{

        alert("If Condition approached");

        alert(shopRecords[0].attributes.new_shoppingname.value);

    //}

    alert("Finished");


    }

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: FetchXml Querry is not working.

    Its done.

    There is an error in 3rd Line on alert function of (")

    alert("Function approached");

    I have placed a single quotes that's y It was giving an error.

    Thanks Scott for finding an error and help me out to solve it.

    Thanks.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: FetchXml Querry is not working.

    Hi Scott.

    I have remove an error but still same message ShoponLoad is not defined at eval.

  • Suggested answer
    ScottDurow Profile Picture
    ScottDurow 50,177 on at
    RE: FetchXml Querry is not working.

    Hi,

    It looks like you have a syntax error.

    Change}// to //}

    Hope this helps

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans