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

Call Html webresource on ribbon button click

(0) ShareShare
ReportReport
Posted on by 267

I am having a ribbon button, when i click it the javascript triggers. it has a function to open html webresource.

Javascript contains data that needs to be displayed on the grid in html. 

html grid is displaying with columns but no data. script is working fine.

My question:

1) how to pass the data from javascript to html webresource? 

I have the same question (0)
  • Suggested answer
    MikeC282 Profile Picture
    2,175 on at
  • Suggested answer
    cloflyMao Profile Picture
    25,210 on at

    Hi Varma,

    We can pass our data as the third parameter of Xrm.Navigation.openWebResource function.

    pastedimage1594105491781v1.png

    var windowOptions = { height: 400, width: 400 };
    Xrm.Navigation.openWebResource("new_excel",windowOptions, "Dynamics365");

    When the web resource is opened, the passed data will be set as value of data parameter.

    6320.JPG

    Then we can use regex to capture value of specific parameter of URL.(getParameterByName("data");)

    console.log(getParameterByName("data"));
    
    function getParameterByName(name, url) {
        if (!url) url = window.location.href;
        name = name.replace(/[\[\]]/g, '\\$&');
        var regex = new RegExp('[?&]'   name   '(=([^]*)|&|#|$)'),
            results = regex.exec(url);
        if (!results) return null;
        if (!results[2]) return '';
        return decodeURIComponent(results[2].replace(/\ /g, ' '));
    }

    4762.JPG

    Regards,

    Clofly

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at

    Hi,

    The parameters you want to pass are: first=First Value&second=Second Value&third=Third Value

    Note

    If you’re adding static parameters using the Web Resource Properties dialog box from the form editor, you can simply paste the parameters without encoding them into the Custom Parameter(data) field. These values will be encoded for you, but you’ll still need to decode them and extract the values in your page.

    For dynamic values generated in code, use the encodeURIComponent method on the parameters. The encoded values should be:

    first%3DFirst%20Value%26second%3DSecond%20Value%26third%3DThird%20Value

    Open the page passing the encoded parameters as the value of the data parameter:

    You can also use parent.Xrm.Page to fetch the data from entity form.

    If found helpful, Please mark my answer verified.

  • cloflyMao Profile Picture
    25,210 on at

    Hi Varma,

    Please kindly let us know that whether any of answer could help you.

    Regards,

    Clofly

  • Amit Prajapati Profile Picture
    162 on at

    Hi Varma,

    Following is prefer way to pass the data from javascript to HTML or WebResource which you have open using .openWebResource().

    1. Create a JSON or Object of your data and convert it into string

    2. Store String Data  in Local Storage of your browser till you require the data

    3. Fetch the String Object and convert it to JSON Object or Object

    4. Detete data after your work done from browser Local Storage

    Following is reference of blog you can refer:

    d365demystified.com/.../

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 70 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

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

#3
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans