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 :
Customer experience | Sales, Customer Insights,...
Answered

Dynamics 365 Javascript Async function and await

(0) ShareShare
ReportReport
Posted on by 2,175

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)
  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    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.

  • MikeC282 Profile Picture
    2,175 on at

    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.

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at

    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!

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 > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 70 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 33 Most Valuable Professional

#3
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans