PCF primary entity info
Getting the primary entity info
At present the PCF Template provided by the Power Apps Cli gives us lots of opportunity and scope to improve functionality, but the type definitions are missing some objects that are present api. Now this could be for many reasons, one being support. Anyway, I’m a rogue so here is one I’ve already used a lot!
The entity id (guid)
1 | const entityId = (context.mode as any).contextInfo.entityId; |
This is the equivalent of the following in the Client API
1 | const entityId = formContext.data.entity.getId(); |
The entity type (entity logical name)
1 | const entityTypeName = (context.mode as any).contextInfo.entityTypeName; |
This is the equivalent of the following in the Client API
1 | const entityTypeName = formContext.data.entity.getEntityName(); |
The record name (primary attribute value)
1 | const entityTypeName = (context.mode as any).contextInfo.entityRecordName; |
This is the equivalent of the following in the Client API
1 | const entityTypeName = formContext.data.entity.getPrimaryAttributeValue(); |
Hopefully this will be helpful to some of you!
Thanks for reading
Ollie
Disclaimer!
Some of the tips ‘n’ tricks in the PCF Tips ‘n’ Tricks category are to be used with caution. Although they may work at the time of writing, they may or may not be officially supported by Microsoft