Skip to content

Commit dbfbeea

Browse files
committed
Add fallback to window.parent.window.Xrm before attempting Xrm.Page since Xrm.Page is very deprecated
1 parent b31c8c4 commit dbfbeea

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/XrmDefinitelyTyped/Resources/dg.xrmquery.web.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1310,12 +1310,20 @@ namespace XQW {
13101310
return GetGlobalContext().getClientUrl();
13111311
}
13121312
} catch (e) {}
1313+
try {
1314+
if (window && window.parent && window.parent.window) {
1315+
const w = <typeof window & { Xrm: any; }>(window.parent.window)
1316+
if (w && w.Xrm && w.Xrm.Utility && w.Xrm.Utility.getGlobalContext) {
1317+
return w.Xrm.Utility.getGlobalContext().getClientUrl();
1318+
}
1319+
}
1320+
} catch (e) {}
13131321
try {
13141322
if (Xrm && Xrm.Page && Xrm.Page.context) {
13151323
return Xrm.Page.context.getClientUrl();
13161324
}
13171325
} catch (e) {}
1318-
throw new Error("Context is not available.");
1326+
debugger; throw new Error("Context is not available.");
13191327
}
13201328

13211329
/**

0 commit comments

Comments
 (0)