cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

Retrieving the ID property of an EntityReference

Hi,

 

I've have just started my adventures in PCF and I have come across a problem I hope someone can help with.

I have created a custom control passing in a dataset which contains an owner column. I am trying to retrieve the id of this owner, by doing the following:

let owner = this._dataset.records[recordId].getValue("ownerid") as ComponentFramework.EntityReference;

TypeScript then offers me the following options in intellisense:

Code_2019-08-01_09-35-01.png

So I choose "owner.id" to get the id.

However, when this code runs this "id" is not the id, but an object containing a property called "guid":

msedge_2019-08-01_09-38-54.png

If I try to use owner.id.guid in my TypeScript file I get an error and it fails to build.

Am I doing something wrong here? I am pretty new to TypeScript so probability is high.

Thanks

Jason

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Power Apps
Power Apps

Re: Retrieving the ID property of an EntityReference

@Anonymous - It's not you, it looks like you've found a bug in our TypeScript type definition file. To work around it, you can modify the file in your project:

Open <project directory>\node_modules\@types\powerapps-component-framework\componentframework.d.ts.

Modify line 1257 from

id: string;

to

id: { guid: string };

This will allow the TypeScript compiler's typechecking to pass.

 

I am in the process of getting our type files and documentation updated to reflect runtime reality; will update the thread once those changes have gone through.

View solution in original post

3 REPLIES 3
Highlighted
Power Apps
Power Apps

Re: Retrieving the ID property of an EntityReference

@Anonymous - It's not you, it looks like you've found a bug in our TypeScript type definition file. To work around it, you can modify the file in your project:

Open <project directory>\node_modules\@types\powerapps-component-framework\componentframework.d.ts.

Modify line 1257 from

id: string;

to

id: { guid: string };

This will allow the TypeScript compiler's typechecking to pass.

 

I am in the process of getting our type files and documentation updated to reflect runtime reality; will update the thread once those changes have gone through.

View solution in original post

Highlighted
Anonymous
Not applicable

Re: Retrieving the ID property of an EntityReference

@GregHurlmanMSFT - Looks like there is a similar issue with the entityType property, the actual property name is etn.

 

I updated line 1262 of the type definition from

entityType?: string;

to

etn?: string;

and it works as expected.

Highlighted
Power Apps
Power Apps

Re: Retrieving the ID property of an EntityReference

@Anonymous Yep, saw that yesterday as well, thanks! I've got a PR open to update our types; as soon as it goes in, if you update the version number of the powerapps-component-framework package to "^1.2.0" and run npm install again, you'll get the changes.

Helpful resources

Announcements
Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Users online (7,646)