Skip to main content
Community site session details

Community site session details

Session Id : 7JOUaeb39mE0vXyrPraMnX
Power Apps - Power Apps Pro Dev & ISV
Answered

In PA editable grid control, index.ts init method, trying to get primaryImageAttribute from context.utils.getEntityMetadata(entityName), which returns primaryImageAttribute as a promise

Like (0) ShareShare
ReportReport
Posted on 19 Dec 2022 14:11:21 by 203

I need to get primaryImageAttribute from the Entity Metadata.

 

I'm wanting to render the primary image column in the grid cell in the CellRendererOverrides.tsx generateCellRendererOverrides function. My generateCellRendererOverrides function works fine ...

 

LozzieD_0-1671450493798.png

 

Now, context.utils.getEntityMetadata(entityName) returns a promise of the EntityMetadata. Here it is in my index.ts init method ...

 

LozzieD_2-1671451178999.png

 

When the EntityMetadata promise appears, the const variable primaryImageAttribute will be set to the primaryImageAttribue returned in the EntityMetadata promise.

 

So, to wait for the EntityMetadata promise and primaryImageAttribute to appear, I've wrapped async around an anonymous function and put await on the primaryImageAttribute variable.

 

There's no red squigglies in CellRendererOverrides.tsx or index.ts.

 

The Dev Tools debugger runs up to "return myValue" in the success function returned by "getMetadata(entityName).then( ..." that supplies the value for my primaryImageAttribute variable ...

 

LozzieD_3-1671451847060.png

And then no further breakpoints are hit.  It just disappears.

 

Any ideas?

 

Or, my handling of the promise / async may be wrong or just simply not destined to work.  If so, is there some non-promise, actual synchronous value, way of getting the primaryImageColumn value from the Entity Metadata?

  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on 20 Dec 2022 at 19:33:31
    Re: In PA editable grid control, index.ts init method, trying to get primaryImageAttribute from context.utils.getEntityMetadata(entityName), which returns primaryImageAttribute as a promise

    Happy to hear that @LozzieD ! So glad I could help!
    Have fun with your new project! 😉

  • LozzieD Profile Picture
    203 on 20 Dec 2022 at 11:55:44
    Re: In PA editable grid control, index.ts init method, trying to get primaryImageAttribute from context.utils.getEntityMetadata(entityName), which returns primaryImageAttribute as a promise

    By George and all the Saints, you nailed it Diana! Thank you!

     

    Can't tell you how long I've laboured over that one as a newbie to the TypeScript, React, Fluent-UI, PCF "stack" above plain old JavaScript. Trying to over-complicate the async goings-on.

     

    I've got my "PowerApps Editable Grid with image column rendered in a cell" project working now ...

     

    LozzieD_0-1671537090088.png

    Your blog always comes out on top for deep-dive insights when searching for PCF resources.  I can see I need to methodically work through it rather than just pick up on the search hits!  Xmas - New Year project ...

     

    Thanks once again.

  • Verified answer
    Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on 19 Dec 2022 at 18:26:40
    Re: In PA editable grid control, index.ts init method, trying to get primaryImageAttribute from context.utils.getEntityMetadata(entityName), which returns primaryImageAttribute as a promise

    Hi @LozzieD , 

     

    Instead of wrapping the async around the anonymous function, register the even right inside your metadata success function.

    DianaBirkelbach_0-1671474199898.png

    I've done the same inside this PAGrid PCF. Have a look: https://github.com/brasov2de/GridCustomizerControl/blob/main/CellRenderer/DianaGridCustomizerControl/index.ts

     

    Maybe my blog might help too: https://dianabirkelbach.wordpress.com/2022/07/27/power-apps-grid-control-first-glimpse-to-the-cell-renderer-and-editors/

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 637 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 570 Super User 2025 Season 2

#3
Power Apps 1919 Profile Picture

Power Apps 1919 473

Loading complete