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

Notifications

Announcements

No record found.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
#ManoVerse Profile Picture

#ManoVerse 93

#1
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 62 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans