Supported way to get Entity Id and Logical Name in PCF

IMPORTANT
Help UKRAINE ! Your action matters! Donate to support Ukrainian Army! Donate to charity funds! Organize/join street protests in your city to support Ukraine and condemn Russian aggression! Expose and report Russian disinformation! #StandWithUkraine

Introduction

What is the question about PCF that we, as developers, were asking the most? I would say probably this one - “What is a supported way to get Entity Id and Logical Name of the entity?”. There were different ways to obtain that information (see my previous post), but we finally got an answer.

Solution

We would need to have two new mandatory fields for our components one for Entity Id and one for Entity Logical Name (you can name them whatever you would like). Their type need to be SingleLine.Text and usage need to be input. Then when configuring those fields the user will need to select “Bind to a value on a field” and in the list of fields the user will be able to see the id field for the entity (accountid for example) and at the end of the list specific field called entitylogicalname, which is self-explanatory.

Id field:

Entity Id

Logical Name field:

Entity Name

Conclusion

So we finally have a “supported way” to get information that we need in our components. However, this requires a bit more action from our users (especially regarding entity id which users might have troubles finding), but at least now we shouldn’t be afraid that our code will stop working as unsupported.