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

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)
  • meelamri Profile Picture
    13,216 User Group Leader on at

    Hi,

    please share your code

  • Suggested answer
    Flydancer Profile Picture
    1,332 on at

    If you have a promise, use the then function:

    insertRecord().then(

       (onResolved) => {

           // retrieve record..

       },

       (onRejected) => {

           // Some task on failure

       }

    )

  • Verified answer
    Inogic Profile Picture
    709 on at

    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!

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