web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Lookups in crm 2011

(0) ShareShare
ReportReport
Posted on by 835

Hello,

I have careated a new lookup on the Cases form called Sales Rep Name. I try to  do an advance find where sales rep name = 'John Doe'. I don't get a results. I have a script that autopopulates the sales rep name lookup field based on Account owner. But if I go in and manually add the rep in the lookup; I get a result.

Any ideas on why autopopulated lookup field doesn't return a result?

 

Jose F

*This post is locked for comments

I have the same question (0)
  • Bruno Lucas Profile Picture
    5,421 on at

    when you say "I have a script that autopopulates the sales rep" did you create a javascript using this:

    msdn.microsoft.com/.../gg334266.aspx

    if you type the correct name straight into a normal crm lookup, it will find the name if it is spelled correctly

    the script should have a FetchXML, does it work correct?

    this type of JS filter code has changed for crm2013. could that have sintax for older versions of CRM?

    do you get any JS error?

    did you try debug it using F12?

    if you are trying to add a value to that field rather than pre-filter it, you may be invoking it on the wrong event.

    can you share the script and the event that invokes it?

    Cheers

  • Suggested answer
    DH kumar CRM Profile Picture
    1,345 on at

    Hi Jose,

    Are you using any javascript code to load data in lookup  on form load event on field change event. Can you try below code with little changes of the fields name wherever it  is required and see if that works... And also refer this post with an example... http://duanenapier.wordpress.com/category/microsoft-dynamics-crm/microsoft-dynamics-crm-2013/ 

    Step 1:  Retrieve the data for the selected City record in your City Lookup using the CRM 2011 REST EndPoint

    Step 2:  Set the value of your Province field with the result of the REST Web Service Query

    The code below is an example you can use with CRM 2011:

    //Retrieve Product

    function RetrieveProvince {

    //Get the Selected City

    if(Xrm.Page.getAttribute("<name_of_city_field_on_case>").getValue() != null)

    {

         var id = Xrm.Page.getAttribute("<name_of_city_field_on_case>").getValue()[0].id;

       var _oPath = Xrm.Page.context.getServerUrl() + "/XRMServices/2011/OrganizationData.svc";

       var _retrieve = new XMLHttpRequest();

       _retrieve.open("GET", _oPath + "/<name_of_city_entity>Set(guid'" + id + "')", true);

       _retrieve.setRequestHeader("Accept", "application/json");

       _retrieve.setRequestHeader("Content-Type", "application/json; charset=utf-8");

       _retrieve.onreadystatechange = function () { RetrieveCityRequestCallback(this); };

       _retrieve.send();

    }

    }

    function RetrieveCitytRequestCallback(_retrieve)

    {

       if(_retrieve.readyState == 4)

       {

           if(_retrieve.status == 200)

           {

               var _city = JSON.parse(_retrieve.responseText).d;

               if(_city.<name_of_province_field>.Value != null)

                {

                        Xrm.Page.getAttribute("<name_of_province_field_on_case>").setValue(_city.<name_of_province_field>.Value;

                }

           }

           else

           {

               window.alert("There was an error retrieving Province Information");

           }

       }

    }

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans