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

How to call a function after another function completed

(0) ShareShare
ReportReport
Posted on by

Good day,

In Javascript, how to call 2 functions but in turn. the 2nd function must be executed after 1st function completed.

So I have a function to insert a new record, then 2nd function is to retrieve the record. Guess by just calling it in 2 lines not working 

Regards,

I have the same question (0)
  • Verified answer
    Inogic Profile Picture
    651 on at
    RE: How to call a function after another function completed

    You can see below example of CRM XRM functions for creating and retrieving data using JavaScript.

    Xrm.WebApi.createRecord("entityName", Your Query").then(
    function success(result)
    {
    Xrm.WebApi.retrieveRecord("entityName ", "Your Query").then(
    function success(result)
    {
    console.log("deleted");
    // perform operations on record deletion
    },
    function (error) {
    console.log(error.message);
    // handle error conditions
    }
    );
    },
    function (error) {
    console.log(error.message);
    // handle error conditions
    }
    );

    Hope this helps.

    Thanks!

  • Suggested answer
    Flydancer Profile Picture
    1,332 on at
    RE: How to call a function after another function completed

    If you have a promise, use the then function:

    insertRecord().then(

       (onResolved) => {

           // retrieve record..

       },

       (onRejected) => {

           // Some task on failure

       }

    )

  • meelamri Profile Picture
    13,216 User Group Leader on at
    RE: How to call a function after another function completed

    Hi,

    please share your code

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
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 258

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 172

#3
Tom_Gioielli Profile Picture

Tom_Gioielli 75 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans