Posts

Showing posts from September, 2019

Promise in JavaScript | Async Calls | Dynamics CRM

I am going to explain how we can use promise in our CRM script with little explanation about promise. Let's suppose you have multiple functions in your script and one of those function (name funA) does take time to execute and other function (name funB) in script depends on the result of that function (funA) result. A 'promise' is a special JavaScript object that links both these functions; funA & funB together. Promise makes the result available to funB when it is ready from functionA. Basic syntax of a promise is: var promise = new Promise( function (resolve, reject) {              //Producing code              let  condition =  1 ;              if  (condition <  1 )                 resolve();              else                 reject();         }); The function passed to new Promise is called the executor. When new Promise is created, it runs automatically. It contains the producing code, that should eventually produce a result.
go to top image