简体   繁体   中英

how to get (ScriptObject)HtmlPage.Window.GetProperty(“Xrm”) in Silverlight Application when it embedded to HTML Page in CRM

I fetch the Guid of Record using below code in Silverlight Application in CRM.

 dynamic xrmnew = (ScriptObject)HtmlPage.Window.GetProperty("Xrm");
 Guid Id1 = new Guid(xrmnew.Page.data.entity.getId());
 textBox2.Text = Id1.ToString();

Thats fine i got the Guid of Record from Silverlight Application using above code.But if i deploy this Silverlight Page in HTML Page and then try to get Guid of Record using above code then it doesnt able to fetch the Guid.

Finally after a lot of hard work i got the answer

dynamic xrmnew = (ScriptObject)HtmlPage.Window.GetProperty("Xrm");
if (xrmnew == null)
{
    HtmlWindow parentWindow = HtmlPage.Window.GetProperty("parent") as HtmlWindow;
    xrmnew = (ScriptObject)parentWindow.GetProperty("Xrm");
}
Guid Id = new Guid(xrmnew.Page.data.entity.getId());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM