1

I have a silverlight webresource in my CRM 2015 online, that I open using a javascript webresource. This web resource is through a ribbon button of the Opportunity entity. I need to pass the current opened opportunity to the silverlight web resource. I've managed to get the OpportunityId but still I can't pass it to the Silverlight web resource.

My javascript webresource code:

function OpenSilverLightControl()
 {
     var Id=Xrm.Page.data.entity.getId();

    window.open('https://crm.mycrm.com//WebResources/new_/MyCRMQuoteTestPage.html',null,500,600);
 }

EDIT:

I tried using QueryString but it produces an Internal Server Error.

This is my link: https://crm.mycrm.com//WebResources/new_/mycrmOpportunityQuoteTestPage.html?oppid={7A594863-1C1F-E511-80C8-02E7484A2B2F}

also this : https://crm.mycrm.com//WebResources/new_/mycrmOpportunityQuoteTestPage.html?oppid=7A594863-1C1F-E511-80C8-02E7484A2B2F

both give "500 - Internal server error"

user3340627
  • 3,023
  • 6
  • 35
  • 80

3 Answers3

2

This is normally done using a query string variable

function OpenSilverLightControl(){
    var Id=Xrm.Page.data.entity.getId();
    var url = 'https://crm.mycrm.com//WebResources/new_/MyCRMQuoteTestPage.html?elementid=' + Id;

    window.open(url,null,500,600);
}

Then in the Silverlight application you can read the querystring value

jasonscript
  • 6,039
  • 3
  • 28
  • 43
  • I tried that and I got Server Error: "500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed." – user3340627 Jul 02 '15 at 13:03
  • This is my link: https://crm.mycrm.com//WebResources/new_/mycrmOpportunityQuoteTestPage.html?oppid={7A594863-1C1F-E511-80C8-02E7484A2B2F} also this : https://crm.mycrm.com//WebResources/new_/mycrmOpportunityQuoteTestPage.html?oppid=7A594863-1C1F-E511-80C8-02E7484A2B2F both give "Server not found error" – user3340627 Jul 02 '15 at 13:10
1

Add it as querystring and parse it in your Silverlight webresponse?

You could do it like:

window.open('https://crm.mycrm.com//WebResources/new_/MyCRMQuoteTestPage.html?id='+id' 

And in your Silverlight resource:

function getQueryString (name) {
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for (var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars[strName];
}

And call the function like: getQueryString("id");

Luca
  • 1,766
  • 3
  • 27
  • 38
  • I tried that and I got Server Error: "500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed." – user3340627 Jul 02 '15 at 13:04
1

From user3491963 answer in this question as well as jasonscript and Unlockedluca answers in the current question,
I was able to use the Querystring parameter BUT it has to be with name "data" any other name won't work.

Community
  • 1
  • 1
user3340627
  • 3,023
  • 6
  • 35
  • 80