DEV Community

Oliver Flint
Oliver Flint

Posted on • Originally published at oliverflint.co.uk on

1 1

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)

const entityId = (context.mode as any).contextInfo.entityId;
Enter fullscreen mode Exit fullscreen mode

This is the equivalent of the following in the Client API

const entityId = formContext.data.entity.getId();
Enter fullscreen mode Exit fullscreen mode

The entity type (entity logical name)

const entityTypeName = (context.mode as any).contextInfo.entityTypeName;
Enter fullscreen mode Exit fullscreen mode

This is the equivalent of the following in the Client API

const entityTypeName = formContext.data.entity.getEntityName();
Enter fullscreen mode Exit fullscreen mode

The record name (primary attribute value)

const entityTypeName = (context.mode as any).contextInfo.entityRecordName;
Enter fullscreen mode Exit fullscreen mode

This is the equivalent of the following in the Client API

const entityTypeName = formContext.data.entity.getPrimaryAttributeValue();
Enter fullscreen mode Exit fullscreen mode

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

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay