Typescript Window Dynamics CRM window.parent

Since I use webresource in my CRM functionality, I need to use

window.parent.Xrm.Page...etc 

to access entity data.

Unfortunately, since I write in typescript, this construct will not compile. At the moment, I'm just adding window.parentup to Xrm.Page... (I got the Xrm credits) manually, but this is very far from the idea of ​​TypeScript. Is there some way, some typical or so, that will allow me to call window.parent.Xrm in a normal, elegant way? I am using Visual Studio

+4
source share
2 answers

, , window.Xrm, , .

ts - i.e.:

Install-Package xrm.TypeScript.DefinitelyTyped

,

class Bar {
    constructor(private xrm: Xrm.XrmStatic) {}
    foo() {
        //work in strongly typed world
        //return this.xrm.Page....;
    }
}

var bar = new Bar(window.Xrm);  
bar.foo();
0

(<any>window.parent).Xrm. , window.parent.Xrm. :

let nameAttr = (<any>window.parent).Xrm.Page.data.entity.attributes.get("name").getValue()
0

All Articles