web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

Async EnableRule for Ribbon blocks rendering

(1) ShareShare
ReportReport
Posted on by 5

We have an EnableRule (JS) for a ribbon button. Because it calls an api, it takes a bit and hence, should be async. The following implementation ilustrates the problem:

export async function ribbonEnabled():Promise<boolean> {
   setInterval(() => {console.log(new Date().toLocaleTimeString())}, 1000);
   await new Promise(r => setTimeout(r, 7000));
   console.log('sleep is over');
   return true;
} 

Even tough the function is declared as async and awaits the api call (or in the example the timeout), the ribbon is not rendered until a value is returned.

Here you can see that several seconds have passed and no ribbon is rendered: 

5504.png

And as soon as the await procedure is over, the message gets printed and the ribbon is rendered:

7674.png

Is that a known issue? Are there any workarounds? I have seen solution where the function is synchronous, returns a boolean variable and in a promis changes this variable and calls ui.refreshRibbon. But this is not adviced and runs the whole function again, so more logic is needed.

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    You can use the approach I used before Promise pattern was provided - butenko.pro/.../

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Pallavi Phade Profile Picture

Pallavi Phade 102 Super User 2026 Season 1

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 55 Super User 2026 Season 1

#3
ManoVerse Profile Picture

ManoVerse 53 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans