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)
const entityId = (context.mode as any).contextInfo.entityId;
This is the equivalent of the following in the Client API
const entityId = formContext.data.entity.getId();
The entity type (entity logical name)
const entityTypeName = (context.mode as any).contextInfo.entityTypeName;
This is the equivalent of the following in the Client API
const entityTypeName = formContext.data.entity.getEntityName();
The record name (primary attribute value)
const entityTypeName = (context.mode as any).contextInfo.entityRecordName;
This is the equivalent of the following in the Client API
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
Top comments (0)