title: ECMAScript Callback method executed after PreSaveAction method
body: <p>My requirement is to get value from another list and set it to SharePoint list form and then save the item. </p>
  
  <p>I wrote ECMAScript and PreSaveAction(). However, PreSaveAction() return true is executed before ECMAScript call back method, which is why my field value is not saved when I click Save button. Please note that my call back function has no error and I get correct value in alert. I don't know where I am doing wrong. Below is my code for you reference.</p>
  
  <pre><code>function PreSaveAction() 
      { 
          ExecuteOrDelayUntilScriptLoaded(GetTotalAmtAlloted, "sp.js");
          return true;**//This line will execute before my callback function onListItemsLoadSuccess or onQueryFailed execute. Because of this, my field value not able to save it.**
  
      }
  
  
   function GetTotalAmtAlloted()
      {
          var clientContext = null;
          var web = null;
          var vID;
  
          clientContext = new SP.ClientContext.get_current();
          web = clientContext.get_web();
          var list = web.get_lists().getByTitle("Investment");
          var camlQuery = new SP.CamlQuery();
  
          var q = "&lt;View&gt;&lt;Query&gt;&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name='InvestmentSubject' /&gt;&lt;Value Type='Text'&gt;abc&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;&lt;/Query&gt;&lt;/View&gt;";
  
          camlQuery.set_viewXml(q);
  
          listItems = list.getItems(camlQuery);
  
          clientContext.load(listItems);
          clientContext.executeQueryAsync(onListItemsLoadSuccess,onQueryFailed);//After this line "return true" in PreSaveAction() will execute and then CallBackMethods will run.
  
  }
  
  function onListItemsLoadSuccess(sender, args) 
  {
    $("input[Title='Total Amount']").val("1000");
  
  }
  
   function onQueryFailed(sender,args)
   {
    alert("error");
   }
  </code></pre>