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)

'LookupObjectsWithCallback' is undefined - show lookup dialog v9.0 error

(0) ShareShare
ReportReport
Posted on by 115

I am trying to open the lookup dialog on click of a button using the following syntax,

Xrm.Utility.lookupobjects(lookupoptions).then(successcallback,cancelcallback)

I am getting a 'LookupObjectsWithCallback is undefined' error , is this not supported in v9.0 ? or am i missing something ?

Thanks in advance

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Arun Vinoth Profile Picture
    11,615 Moderator on at

    It’s totally supported, even introduced in v9 only.

    Check this with your code www.inogic.com/.../show-lookup-dialog-in-dynamics-365-v9-0

    You can debug & see what’s wrong & where.

    Share the code if you don’t mind.

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi,

    This method is introduced in V9 and is supported. Check if you have set the properties correctly. You can refer the above suggested blog which has the working sample. to simply & isolate the issue, try calling you code from an onchange field event instead of button. It is possible that this is not working within that context for some reason.

    Hope this helps.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi SR,

    Could you please share your whole code here .

    Seems you have not declared call back method like below.Also you need to check you are passing correct parameter in lookupoptions object.

    Xrm.Utility.lookupobjects(lookupoptions).then(successcallback,cancelcallback)

    function successcallback()

    {

    }

    function cancelcallback()

    {

    }

    For more information you can refer below article-

    howto-mscrm.com/.../dynamics-365-v9-0-show-lookup-dialog-is-here.html

  • Sumisrinivasan Profile Picture
    115 on at

    Thanks everyone for your response , here is what i am trying to do

    function openLookup(){

                                       var lookupParam = {};

                                       lookupParam.entityTypes = ["quote"];

                                       lookupParam.defaultEntityType = "quote";

                                       lookupParam.defaultViewId = "{8BBC8212-4A27-E811-80EF-3863BB3610E8}";

                                       lookupParam.allowMultiSelect = false;

                                       Xrm.Utility.lookupObjects(lookupParam).then(CallbackFunction,null);

    }

                                   function CallbackFunction(event) {

                                       var name = event[0].name;

                                       var id = event[0].id;

                                       document.getElementById('quote').value = name;

                                   }

    I did refer the blogs and also tried to debug before posting my question here , i am not able to figure out where i am going wrong . I am initially just trying to check if the lookup opens on button click before i add any other code to it .

  • Suggested answer
    Shaminderpal Singh Profile Picture
    1,565 on at

    Hi-

    Are you calling it from html web resource?

    If yes, then try to access using window.parent.Xrm.Utility.lookupObjects(lookupParam).then(CallbackFunction,null);

    -Shaminder

  • Sumisrinivasan Profile Picture
    115 on at

    I am using window.parent when calling it from html web resource , i get the same error . I don't think that is causing this error .

  • Suggested answer
    Arun Vinoth Profile Picture
    11,615 Moderator on at

    If you would have followed the link I shared earlier - you can double check whether you have added this script file reference in your HTML web resource.

    <script src="../../../../_static/_controls/lookup/lookup.js"></script>

  • Sumisrinivasan Profile Picture
    115 on at

    I am getting the same error even after adding the reference

  • Suggested answer
    Arun Vinoth Profile Picture
    11,615 Moderator on at

    This ../../../../ depends on your name (folder structure) of web resource. It may have extra or less depends on your project.

    You have to add more details rather than one line responses. You have to try something & share what are all you tried.

  • Suggested answer
    Shaminderpal Singh Profile Picture
    1,565 on at

    Are you attaching your html web resource to entity form or opening it as a stand alone page?

    Also, would it be possible for you to share your web resource naming convention to help determine the source of referenced script?

    Web Resource Naming - new_lookup.js (without any folder structure)

    Below Code is working for me :

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8" />
    <title></title>
    <script src="ClientGlobalContext.js.aspx" type="text/javascript"></script>
    <script src="../_static/_controls/lookup/lookup.js"></script>
    <script>
    function lookupclick() {
    Xrm.Utility.lookupObjects({
    allowMultiSelect: false,
    defaultEntityType: 'contact',
    defaultViewId: 'A2D479C5-53E3-4C69-ADDD-802327E67A0D',
    entityTypes: ['contact']
    }).then(function (success) {
    console.log('Captured Response', success);
    }, function (cancel) {

    });
    }

    </script>
    </head>
    <body>
    <button id="lookup" onclick="lookupclick()">Lookup</button>

    </body>
    </html>

    Hope it helps.

    -Shaminder

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