web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

How to get Customer Parameter values in HTML Webresource when opened with Xrm.Navigation.openWebResource

(0) ShareShare
ReportReport
Posted on by 485

Hello,

Iam opening html web resource on button click and want to pass few values to webresource and but unable to retrieve values in html  on load. Please help

i am using below code to open web resource

var windowsOption = { height: 500, width: 830, openInNewWindow: true };
var customParameters = encodeURIComponent("URL=" + orgURL +"&CategoryId=" +pCategoryId);
Xrm.Navigation.openWebResource("fcpm_DisplayActivities_html", windowsOption, customParameters);

HTML web resource on load trying to retrieve values of URL and CategoryId

var url= getUrlVars()["URL"];

function getUrlVars()
{
var vars = [], hash;
var hashes = unescape(window.location.search.replace('?', ''));
hashes = hashes.replace('Data=', '').replace('data=', '').split(',');
for (var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}

 here i am unable to get values of URL and CategoryId Please help.

Thanks

I have the same question (0)
  • Suggested answer
    ajyendra Profile Picture
    1,738 on at

    Hi Krishna,

    Check this Similar Forum :

    community.dynamics.com/.../xrm-navigation-openwebresource-sample-code

    Hope it helps

  • dkrishna Profile Picture
    485 on at

    I have seen earlier that post but didnt worked. Can you pls help

  • Suggested answer
    ajyendra Profile Picture
    1,738 on at

    Hi Krishna ,

    Made some Changes on Code

    function getValue(values){

       if(values!= "")

           alert(decodeURIComponent(values));

    var value = decodeURIComponent(values);

    var vals = new Array();

    vals =value.split("&");

    for (var i in vals) {

        vals[i] = vals[i].replace(/\+/g, " ").split("=");

       }

    // this will give you a result like on vals variable

    //0: "URL=/asdasd/asdas/dasdasdas"

    //1: "CategoryId=12313123131"

    }

    function getUrlVars(){

    debugger;

    var vals = new Array();

      if (location.search != "") {

    //var tt = decodeURIComponent(location.search);

       vals = location.search.substr(1).split("&");

       for (var i in vals) {

        vals[i] = vals[i].replace(/\+/g, " ").split("=");

       }

       //look for the parameter named 'data'

       var found = false;

       for (var i in vals) {

        if (vals[i][0].toLowerCase() == "data") {

         getValue(vals[i][1]);

         found = true;

         break;

        }

       }

       if (!found)

       { alert('no Parameter');}

      }

      else {

       alert('no Parameter');;

      }

    }

    getUrlVars();

    For Calling javascript

    var windowsOption = { height: 500, width: 830, openInNewWindow: true };

    var customParameters = "URL=" + orgURL +"&CategoryId=" +pCategoryId;

    Xrm.Navigation.openWebResource("fcpm_DisplayActivities_html", windowsOption, customParameters);

    Now you can manipulate that variable as per your requirement

  • dkrishna Profile Picture
    485 on at

    Hello Ajyendra Singh,

    Thanks for the help.

    Iam not able to get URL value from above code

    in the vals[i] = vals[i].replace(/\+/g, " ").split("="); getting below value instead of URL value.

    URL%3Dhttps%3A%2F%2Ffieldcomplex.crm6.dynamics.com%26projectSubCategoryId%3D723b0fd5-74cf-e911-a813-000d3a79607

    Pls suggest how to get URL value.

  • Suggested answer
    ajyendra Profile Picture
    1,738 on at

    Hi Krishna ,

    Please Make Sure Use all my code I have change code now it will the return the result

    result value be like

    0: (2) ["URL", "/asdasd/asdas/dasdasdas"]

    1: (2) ["CategoryId", "12313123131"]

    You can use it like result[0][1] to get Url and result[1][1] for Category

    below is updated code

    function getValue(values){

       if(values!= "")

           //alert(decodeURIComponent(values));

    var value = decodeURIComponent(values);

    var vals = new Array();

    var resultSet = new Array();

    vals =value.split("&");

    for (var i in vals) {

        vals[i] = vals[i].replace(/\+/g, " ").split("=");

        resultSet.push(vals[i]);

       }

    return resultSet;

    }

    function getUrlVars(execContext){

    var vals = new Array();

    var result = new Array();

      if (location.search != "") {

       vals = location.search.substr(1).split("&");

       for (var i in vals) {

        vals[i] = vals[i].replace(/\+/g, " ").split("=");

       }

       //look for the parameter named 'data'

       var found = false;

       for (var i in vals) {

        if (vals[i][0].toLowerCase() == "data") {

         result = getValue(vals[i][1]);

         found = true;

         break;

        }

       }

       if (!found)

       { alert('no Parameter'); }

      }

      else {

       alert('no Parameter');;

      }

      return result;

    }

    getUrlVars();

    For Calling javascript

    var windowsOption = { height: 500, width: 830, openInNewWindow: true };

    var customParameters = "URL=" + orgURL +"&CategoryId=" +pCategoryId;

    Xrm.Navigation.openWebResource("fcpm_DisplayActivities_html", windowsOption, customParameters);

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

    Hi Krishna,

    Hope below reference helps you -

    https://butenko.pro/2015/03/01/howto-htmljs-webresources/

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 180 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 119

#3
CU11031447-0 Profile Picture

CU11031447-0 100

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans