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,
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!
If you have a promise, use the then function:
insertRecord().then(
(onResolved) => {
// retrieve record..
},
(onRejected) => {
// Some task on failure
}
)
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Andrés Arias as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Rishabh Kanaskar 258
Daniyal Khaleel 172
Tom_Gioielli 75 Super User 2025 Season 2