Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Unanswered

return value of dialog box

Posted on by 20
Hello everyone!

I'm using the following code:

OpenLookup: function () {
        let opcoesDialogo = new Xrm.DialogOptions;
        opcoesDialogo.width = 600;
        opcoesDialogo.height = 520;
        opcoesDialogo.left = 0;
        opcoesDialogo.right = 0;
        let urlServidor = Xrm.Page.context.getClientUrl ();
        Xrm.Internal.openDialog (urlServidor + "/_controls/lookup/lookupsingle.aspx?class=null&objecttypes=3&browse=0&ShowNewButton=0&ShowPropButton=0&DefaultType=0", optionsDialogo, null, null, CallbackFunction);
     
        function CallbackFunction (returnValue) {
            alert (returnValue.items [0] .name);
        }
    }

I'm just trying to display the name of the record I selected for testing purposes, but it doesn't appear in the alert.

How is it possible to get the attributes of the item that I selected in the dialog box?
6138.help.jpg
  • a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: return value of dialog box

    Can you please provide full code of your webresource?

  • cloflyMao Profile Picture
    cloflyMao 25,198 on at
    RE: return value of dialog box

    Hi Partner,

    Could you share your crm version?

    Xrm.Internal.openDialog is a unpublished api, if you would like to get a selected record from lookup dialog,

    please use "Xrm.Utility.lookupObjects" as alternative.

    My environment is online(v9.1), the api no longer works in legacy web client, so I tested it in UCI.

    showLookupDialog();
    
    function showLookupDialog() {
    
        try {
    
            var lookupParameters = {};
    
            lookupParameters.entityTypes = ["opportunity"];
    
            lookupParameters.defaultEntityType = "opportunity";
    
            lookupParameters.allowMultiSelect = false;
    
            Xrm.Utility.lookupObjects(lookupParameters).then(DisplaySelectedRecord, null);
    
        } catch (e) {
    
            Xrm.Utility.alertDialog(e.message);
    
        }
    
    }
    
    function DisplaySelectedRecord(selectedRecord) {
    
        try {
    
            if (selectedRecord != undefined && selectedRecord != null && selectedRecord != "")
    
            alert(selectedRecord[0].name);
    
        } catch (e) {
    
            Xrm.Utility.alertDialog(e.message);
    
        }
    
    }

    I execute my code in console directly.(If you could still run the api successfully in legacy web client in your environment, then it'll pou up same dialog as you posted.)

    pastedimage1585813958289v1.png

    After I selected a record and click "Add" button, then I'll get name attribute in alert.

    pastedimage1585814121079v2.png

    An introduction article about the api:

    https://www.inogic.com/blog/2018/06/show-lookup-dialog-in-dynamics-365-v9-0/

    Regards,

    Clofly

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,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans