Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

We are not able to pass input parameters to html web-resource from entity form.

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Requirement:

We would like to open and pass input parameters to an HTML web-resource in CRM Modal Dialog box after user clicks on a custom ribbon button on the entity Form. HTML web-resource will, in turn, call external URL using form “post” method. External URL will fetch data using input parameters and display the result in CRM Modal dialog box.

 

Problem Statement:

We are not able to pass input parameters to html web-resource from entity form.

 

*This post is locked for comments

  • Ritesh.ar Profile Picture
    Ritesh.ar 5 on at
    RE: We are not able to pass input parameters to html web-resource from entity form.

    Thanks Mark , It is a perfect solution.

  • MarkR_B Profile Picture
    MarkR_B 465 on at
    RE: We are not able to pass input parameters to html web-resource from entity form.

    Nitinsha

    You can easily open a dialog with the following code

    var currentRecId = window.parent.Xrm.Page.data.entity.getId();
    var someText = "info";
    var addParams = "recordid=" + currentRecId + "&sometext=" + someText;
    //Build the URI
    var src = "/webresources/new_customDialog.htm?Data=" + encodeURIComponent(addParams);
    //Build dialog options
    var DialogOptions = new Xrm.DialogOptions();
    DialogOptions.width = 1300;
    DialogOptions.height = 850;
    
    Xrm.Internal.openDialog(src, DialogOptions, null, null, CallbackFunction);
    //Execute some action on closing of dialog
    function CallbackFunction(returnValue) {
      //Do something with the returned value
    }

    Then within the dialog you can use the following function to get the parameters.

    function ParseQueryString(query) {
      var result = {};
      if (typeof query == "undefined" || query == null) {
         return result;
      }      
      var queryparts = query.split("&");  
      for (var i = 0; i < queryparts.length; i++) {
         var params = queryparts[i].split("=");
         result[params[0]] = params.length > 1 ? params[1] : null;
      }
      return result;
    }

    Then to get the parameters use the function as such

    //Get the parameters passed
    var passedparams = ParseQueryString(GetGlobalContext().getQueryStringParameters()["Data"]);
    
    //Populate the property ID
    var currentRecId = passedparams.recordid;
    var someText= passedparams.sometext;

    One thing to note, you will run into cross domain issues if you are obtaining data from a seperate domain. Take a look at this thread it may be of use to you https://community.dynamics.com/crm/f/117/t/137165.aspx. I have used Actions to owvercome this and it works well.

    Hope this helps 

    Mark

  • Royal King Profile Picture
    Royal King 27,686 on at
    RE: We are not able to pass input parameters to html web-resource from entity form.

    Are you calling any javascript function to open modal dialogue? if so you can easily pass record values as query string parameter to the Dialogue window.

    find below sample code to pass multiple values

    var customParameters = encodeURIComponent("first=First Value&second=Second Value&third=Third Value");

    Xrm.Utility.openWebResource("new_webResource.htm",customParameters);

    detailed information on passing multiple values to web resouce can be found here

    msdn.microsoft.com/.../jj602956.aspx

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,965 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,817 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans