如何将当前实体 ID 传递到我的 Silverlight Web 资源?
How to pass current entity Id to my Silverlight webresource?
我的在线 CRM 2015 中有一个 silverlight 网络资源,我使用 javascript 网络资源打开它。此 Web 资源是通过商机实体的功能区按钮。我需要将当前打开的机会传递给 silverlight 网络资源。我已成功获取 OpportunityId,但仍无法将其传递给 Silverlight Web 资源。
我的 javascript 网络资源代码:
function OpenSilverLightControl()
{
var Id=Xrm.Page.data.entity.getId();
window.open('https://crm.mycrm.com//WebResources/new_/MyCRMQuoteTestPage.html',null,500,600);
}
编辑:
我尝试使用 QueryString,但它产生了内部服务器错误。
这是我的 link:https://crm.mycrm.com//WebResources/new_/mycrmOpportunityQuoteTestPage.html?oppid={7A594863-1C1F-E511-80C8-02E7484A2B2F}
都给出“500 - 内部服务器错误”
这通常是使用查询字符串变量完成的
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);
}
然后在 Silverlight 应用程序中您可以读取查询字符串值
将其添加为查询字符串并在您的 Silverlight webresponse 中解析它?
你可以这样做:
window.open('https://crm.mycrm.com//WebResources/new_/MyCRMQuoteTestPage.html?id='+id'
并且在您的 Silverlight 资源中:
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];
}
并调用如下函数:getQueryString("id");
来自 user3491963 在 问题中的回答
以及当前问题中的 jasonscript 和 Unlockedluca 答案,
我能够使用 Querystring 参数 但它必须使用名称“data”,任何其他名称都不起作用。
我的在线 CRM 2015 中有一个 silverlight 网络资源,我使用 javascript 网络资源打开它。此 Web 资源是通过商机实体的功能区按钮。我需要将当前打开的机会传递给 silverlight 网络资源。我已成功获取 OpportunityId,但仍无法将其传递给 Silverlight Web 资源。
我的 javascript 网络资源代码:
function OpenSilverLightControl()
{
var Id=Xrm.Page.data.entity.getId();
window.open('https://crm.mycrm.com//WebResources/new_/MyCRMQuoteTestPage.html',null,500,600);
}
编辑:
我尝试使用 QueryString,但它产生了内部服务器错误。
这是我的 link:https://crm.mycrm.com//WebResources/new_/mycrmOpportunityQuoteTestPage.html?oppid={7A594863-1C1F-E511-80C8-02E7484A2B2F}
都给出“500 - 内部服务器错误”
这通常是使用查询字符串变量完成的
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);
}
然后在 Silverlight 应用程序中您可以读取查询字符串值
将其添加为查询字符串并在您的 Silverlight webresponse 中解析它?
你可以这样做:
window.open('https://crm.mycrm.com//WebResources/new_/MyCRMQuoteTestPage.html?id='+id'
并且在您的 Silverlight 资源中:
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];
}
并调用如下函数:getQueryString("id");
来自 user3491963 在
我能够使用 Querystring 参数 但它必须使用名称“data”,任何其他名称都不起作用。