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)

Set default view in inline lookup.

(0) ShareShare
ReportReport
Posted on by 290

Hi All, 

I have requirement to set another lookup instead of associate lookup coming here bydefault. kindly let me know the supported way to done it.

ViewLookup.JPG

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Tobias Koller Profile Picture
    on at
  • Mohammad Sharique Profile Picture
    290 on at

    Hi Koller, Thanks to help me on this. but no i dont want this one.

    i want to set view to the lookup. as did in below link using unsupported way. but same thing looking in supported way. is it possible.

    nycrmdev.blogspot.dk/.../changing-default-view-of-inline-lookup.html

  • Verified answer
    Tobias Koller Profile Picture
    on at

    yes, you can simply call this:

    Xrm.Page.getControl("parentaccountid").setDefaultView("{61273827-328E-E011-95AE-00155D9CFA02}");


     

    The Id is the id of the view you want to auto-select.

    the easiest way to find out the id of the view is to open the lookup-view and check the picklist inside the dom:

    setDefaultView.PNG

  • Mohammad Sharique Profile Picture
    290 on at

    I am in new in javascript can you please explain me step by step where i have to use javascript in crm. please help me to solve this. Thanks in advance.

  • Tobias Koller Profile Picture
    on at

    well I don't know your skills but i will try to explain:

    you simply have to call this function in your onload-function of the form:

    1. Create a webresource (Javascript-File) in CRM

    2. Put the following code in your newly created webresource (Change the "parentaccountid" with the Name of your lookupfield and Change the ID of the view to your view's id)

    function setLookupView()
    {
        Xrm.Page.getControl("parentaccountid").setDefaultView("{61273827-328E-E011-95AE-00155D9CFA02}");
    }


     3. open the form-Editor of the entity you want to run the script in

    form2.PNG

    4. open Form-Properties and add the webresource

    form2.PNG

    5. add Onload-Function

    form3.PNG

    that should do the Magic ;)

  • Mohammad Sharique Profile Picture
    290 on at

    Thanks Koller, but i dont have lookup on form, i have marketing list grid on contact form.

    When i click on "+" button of marketing list grid its shows that window lookup for more record and view is selected bydefault i want to change there.

    Lookup is not there directly on form. hope you understand my problem.

    If require please let me know to put all screen step by step.

  • Suggested answer
    Tobias Koller Profile Picture
    on at

    ok, now i see your problem ;)

    I just tried to set the filter to the inline-lookup and it worked as followed:
    This script is only using supported ways!

    The only little "disadvantage" is that the script has to check every (here 500ms) if the lookup is available because the lookup is added dynamically to the dom.
    But this shouldn't cost to much performance. You could also increase the 500 if you want to (f.e. 1000).

    You only have to adjust two fields:
    1. set the control-name (here "lookup_Marketinglists") to the name of your Marketing-subgrid-name and add the prefix "lookup_". (This is Case-Sensitive!!)

    1447.marketinglist.PNG

    2. set the ID to your view-ID (like i described in previous posts)

    function setMarketingLookupFilter(){
        
        var lookup = Xrm.Page.getControl("lookup_Marketinglists");
    
        if(lookup)
        {
            var id = "{7D7737D8-1A05-4ABB-BEBD-843404A83DAD}";
            var defaultView = lookup.getDefaultView();
            
            if(defaultView != id) {
                lookup.setDefaultView(id);
            }    
        }
        
        setTimeout(
            function(){
                setMarketingLookupFilter();
            }
        , 500);
        
    }

    (Please remove the line-numbers of the script ;) )


    best regards
    Tobias

  • Mohammad Sharique Profile Picture
    290 on at

    Hi Tobias,

    Always "lookup" value is coming null, its not finding the value of lookup, and the same i can get using getElementById function which not supported way. Plz let me know.

    sharing my temp organization could you please do here the same i need. its my request.

    Online Ogr URL: punesoft.crm5.dynamics.com/main.aspx;page=Settings&area=nav_administration#736986542

    UserName: m.sharique@punesoft.onmicrosoft.com

    Password: *******

  • Tobias Koller Profile Picture
    on at

    remove your credentials!!!!! i will try it. but don't post credentials!

  • Tobias Koller Profile Picture
    on at

    in your environment there is no marketing list-subgrid on contact-form.

    i will add one to let you see how it works.

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