title: TypeScript call async function from synchronous function and return boolean
body: <p>How can I call a asynchronous function from a synchronous function. I don't get it.</p>
  
  <pre><code>function showOpenCaseDialog(): boolean {
  
      let result = false;
  
      var regardingobjectid = (&lt;Xrm.LookupAttribute&lt;string&gt;&gt;Xrm.Page.getAttribute("regardingobjectid")).getValue();
      if (regardingobjectid != null &amp;&amp; regardingobjectid.length &gt; 0) {
          var regardingobject = regardingobjectid[0];
          if (regardingobject.entityType === "incident") {
              checkCaseLastOpenActivity(regardingobject).then(x =&gt; result = x);
          }
      }
  
      return result;
  };
  </code></pre>
  
  <p>checkCaseLastOpenActivity is the asynchronous function. </p>
  
  <p>The problem is, that the return result is called before the asynchronous is finished.</p>
  
  <p>How can I solve this problem?</p>