-1

Can anyone help me get the values.

I know there are few question asked about it but I could not frame my logic for given values.

I have a URL as below

http://crm//WebResources/abaxis_popup?Data=recordid%3dElectrolyte%26sometext%3daw_device%26somemoretext%3dpolyclinic

I have variables and data as follows


var addParams =encodeURIComponent( "recordid=" + entityLabel + "&sometext=" + entityName + "&somemoretext=" +entityId);
Xrm.Utility.openWebResource('abaxis_popup',addParams ,280,200);

recordId=Electrolyte

sometext =aw_device

somemoretext=polyclinic
Pogrindis
  • 7,755
  • 5
  • 31
  • 44
AnkUser
  • 5,421
  • 2
  • 9
  • 25

1 Answers1

0

NOTE: Just to let you know, you're URL formatting is also incorrect.

Your URL is http://crm//WebResources/abaxis_popup?Data=recordid%3dElectrolyte

Which translates to http://crm//WebResources/abaxis_popup?Data=recordid=Electrolyte

The double ='s after recordid is breaking your GET parameters.

So the Data param is being set to recordid before anything else happens. Not sure what you want to do here.

In order to remove this from the URL string you could use the following :

urlString = urlString.replace(/Data=/g, '');

As suggested you are posting a duplicate question with a slight difference in HTML URL format.

You have HTML chars instead of regular strings.

So convert them back. Our string URL

var urlString = "http://crm//WebResources/abaxis_popup?Data=recordid%3dElectrolyte%26sometext%3daw_device%26somemoretext%3dpolyclinic";

Replace the HTML chars to the regular text chars.

urlString = urlString.replace(/%26/g, '?');
urlString = urlString.replace(/%3d/g, '=');

Use the function in the duplicate question answer to parse the params and values Generously contributed by : weltraumpirat

function transformToAssocArray( prmstr ) {
    var params = {};
    var prmarr = prmstr.split("&");
    for ( var i = 0; i < prmarr.length; i++) {
        var tmparr = prmarr[i].split("=");
        params[tmparr[0]] = tmparr[1];
    }
    return params;
}

Use it.

var result = transformToAssocArray(urlString);

A working example of the proceedure : JSFiddle

Community
  • 1
  • 1
Pogrindis
  • 7,755
  • 5
  • 31
  • 44
  • Thank you for ur reply.Yes it is duplicate question and since 4-5 hrs I was trying to work on available ans here but as I said it is mere my Lack ok knowledge and understanding,hence I asked particular to my url. Also I am trying to call html script in crm with some local values from crm in url and retrieve those values and use in HTML so that I can save them as PDF. ------------------------------- I tried entire code but when I use alert(result); it gives "object" as o/p I also tried alert(result.sometext); AS sometext in url has electrolyte value but i m getting "undefined" as o/p. Thanks – AnkUser Jan 28 '16 at 13:24
  • AS you said my url is also wrong how can I improve it so that I get correct result var addParams =encodeURIComponent( "recordid=" + entityLabel + "&sometext=" + entityName + "&somemoretext=" +entityId); Xrm.Utility.openWebResource('abaxis_popup',addParams ,280,200); – AnkUser Jan 28 '16 at 13:30
  • 1 question who should i use result to get value. I am getting correct url now without data=recordid= but when I refer other variable lie sometext it still gives me undefinied – AnkUser Jan 28 '16 at 14:14
  • @AnkushChikhale I have updated the answer to include parsing the DATA= out – Pogrindis Jan 28 '16 at 14:46