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 :
Customer experience | Sales, Customer Insights,...
Suggested Answer

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

(0) ShareShare
ReportReport
Posted on by 483

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.

I have the same question (0)
  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    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();
    }
    

  • dkrishna Profile Picture
    483 on at

    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.

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 > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 96 Super User 2025 Season 2

#2
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans