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

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Dynamics 365 Javascript Async function and await

(0) ShareShare
ReportReport
Posted on by 2,165

Hi all,

Quick question. With javascript web resources. Is it possible to use an async function as opposed to the traditional function we've all been using? 

So instead of:

function sampleFunctionOne(executionContext) {
var formContext = executionContext.getFormContext();
console.log(formContext.data.entity.getId())
}

I want to write it like this:

async function sampleFunctionTwo(executionContext) {
var formContext = executionContext.getFormContext();
console.log(formContext.data.entity.getId());
}

Obviously in the second code snippet I didn't call any async functions or use the await syntax but I just wanted to know whether we can use it? Can we add it as per normal to a Dynamics 365 form say on load and call the function the same way as sample function one?

Kind regards,

Mike

I have the same question (0)
  • Suggested answer
    Bipin D365 Profile Picture
    28,981 Moderator on at
    RE: Dynamics 365 Javascript Async function and await

    Hi,

    We can also use promise whilch is helpful in async calls when we need to show/hide ribbon button based on Web API async call.

    Please find below article which explain the same

    debajmecrm.com/.../

    Please mark my answer verified if I were helpful!

  • MikeC282 Profile Picture
    2,165 on at
    RE: Dynamics 365 Javascript Async function and await

    Hi Andrew,

    Thank you for the quick reply. Yes makes sense. I always wondered why alot of Javascript code was still written in ES5. It's fine for the most part except for when we're expecting various async functions to return values then I'm getting callback hell.

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Dynamics 365 Javascript Async function and await

    Hello,

    Generally speaking you can use it and majority of modern browsers will support this syntax. But there is IE11 that is still supported by Dynamics/CDS where this wouldn't work so it's up to you to decide to use this approach or not.

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
DAnny3211 Profile Picture

DAnny3211 134

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 106

#3
Abhilash Warrier Profile Picture

Abhilash Warrier 70 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans