Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

How to pass values from html webresource to javascript on window close

Posted on by 475

Hello,

I am opening html webresource using xrm.navigation.openwebresource but on closing of html window i want to pass values from html to javascript file from where it is opened . Is there call back function can be implementes ? 

If i open html window using window.open i can call parent javascript function using window.opener.functionname on close but click but i want to know how i can pass values to parent javascript file on close button click of html window.

  • dkrishna Profile Picture
    dkrishna 475 on at
    RE: How to pass values from html webresource to javascript on window close

    Hi Gautam,

    I have tried as you mentioned but when i tried calling window.parent.opener.updatefields(); getting error as function not defined for updatefields but this function is defined in parent javascript file. please suggest any alternative.

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: How to pass values from html webresource to javascript on window close

    Hi Krishna,

    You  can do following way.Let say I have a JS library which register in the parent form and having a callback function , let say -

    CallbackSetAddress() - 

    if (typeof (CF) == "undefined") { CF = { __namespace: true }; }
    CF.Utility = {    
        CallbackSetAddress: function (addressObj)  {
            if (addressObj != null && addressObj != undefined) {
                Xrm.Page.getAttribute("address1").setValue(addressObj.Address1);
            }
        },
        _namespace: true
    };

    Now from  web Resource access the parent function using  window.parent.opener like below-

    function OnWebResourceClose() {
        var selectedAddress = null;
        selectedAddress["Address1"] = "Line 1";
        window.parent.opener.CF.Utility.CallbackSetAddress(selectedAddress);
        window.close();
    }
    

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