<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Efficy Overflow Q&amp;A - Recent questions tagged asynchronous</title>
<link>https://overflow.efficy.io/?qa=tag/asynchronous</link>
<description>Powered by Question2Answer</description>
<item>
<title>How to queue a function call in a workflow script to execute it async?</title>
<link>https://overflow.efficy.io/?qa=7205/how-to-queue-function-call-in-workflow-script-execute-async</link>
<description>&lt;p&gt;Hi, &lt;/p&gt;

&lt;p&gt;I am working on an integration with Efficy and Exact. One of the flows i need to implement is uploading invoices from exact to Efficy as an attachment. I currently put it in a workflow function and it works fine. However, this flow is very slow (multiple calls to exact so can't make it faster)  and is blocking the end user from doing anything for 20-30 seconds. Is there a way without using schedulers to execute this flow in an async way? A bit like queueing that the  function should be executed in the background. &lt;br&gt;
Or is the only solution using a scheduler service and just use a small time interval? &lt;/p&gt;
</description>
<category>WorkFlow / Serverscript</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=7205/how-to-queue-function-call-in-workflow-script-execute-async</guid>
<pubDate>Wed, 12 Nov 2025 08:29:40 +0000</pubDate>
</item>
<item>
<title>Asynchronous processing the creation of Invoices without freezing Efficy</title>
<link>https://overflow.efficy.io/?qa=2375/asynchronous-processing-creation-invoices-without-freezing</link>
<description>&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;i'm working on a process to handle all or a selection of invoices from the Cash Machine. My intention is to make this process asynchronous without freezing Efficy for the user which starts the process.&lt;/p&gt;

&lt;p&gt;I've managed to create an asynchronous process that sends the invoices but I haven't been able to make the asynchronous process not freezing Efficy.&lt;/p&gt;

&lt;p&gt;What i've got so far is the following:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;        var processList = [];
    function getProcessed(elements) {
        // this function must be inside the outer function
        // so that `i` (below) can be accessed via a closure
        function processElement() {
            // do work on elements[i] here
            // or pass it to another function
            //setTimeout(&quot;&quot;, 10000);
            html = processProject(elements[i]);

            // this continues only if we haven't hit the end of the array,
            // like the second and third clauses of a `for` loop
            if (++i &amp;lt; elements.length) {
                setTimeout(processElement, 0);
            }
        }

        // don't bother with empty arrays
        if (elements.length) {
            processAjaxReturn = true;
            $(&quot;#waitSend&quot;).removeClass(&quot;hide&quot;);
            $(&quot;#soapStatus&quot;).show();

            // the same `i` is used each time processElement runs
            // and acts just like a `for` loop index
            var i = 0;
            var html;

            // optional: make a copy of the array so that it
            // doesn't get modified while we're working
            elements = elements.slice();

            // even a zero-millisecond &quot;delay&quot; gives the browser the
            // opportunity to run other code
            setTimeout(processElement, 0);
        }
    }

    function processAllProjects() {
        requirejs([&quot;misc/utils&quot;], function (Utils) {
            if (document.getElementsByName(&quot;Master&quot;).length &amp;gt; 0 &amp;amp;&amp;amp; document.getElementsByName(&quot;Master&quot;)[0].checked) document.getElementsByName(&quot;Master&quot;)[0].checked = false;
            var extraParams = &quot;queryKey=&amp;lt;%GetArgument('key')%&amp;gt;&quot;;
            Utils.runScriptAjax2(&quot;Invoice&quot;, &quot;getAllProjects&quot;, extraParams, function (args, html) {
                var processList = html.split(&quot;,&quot;);
                countlength = processList.length;
                getProcessed(processList);
            });
        });
    }

    function processSelProjects() {
        if (processList.length === 0) 
            alert(&quot;&amp;lt;%GetLabel('The selection is empty')%&amp;gt;&quot;);
        else {
            if (document.getElementsByName(&quot;Master&quot;).length &amp;gt; 0 &amp;amp;&amp;amp; document.getElementsByName(&quot;Master&quot;)[0].checked) document.getElementsByName(&quot;Master&quot;)[0].checked = false;
            countlength = processList.length;
            getProcessed(processList);
        }
    }

    var processAjaxReturn = false,
        counter = 0,
        countlength;
    function processProject(projKey) {
        try {
            requirejs([&quot;misc/utils&quot;], function (Utils) {
                var extraParams = &quot;K_PROJECT=&quot;+projKey;
                extraParams += &quot;&amp;amp;CashMachCall=1&quot;;
                html = Utils.runScriptAjax2(&quot;Invoice&quot;, &quot;createCashMachineInvoice&quot;, extraParams, function (args, html) {
                    if (html.indexOf(&quot;##_##&quot;) &amp;amp;&amp;amp; html.split(&quot;##_##&quot;)[0] &amp;gt; 0) uncheckCheckbox(projKey);
                    $(&quot;#soapStatus&quot;).html(&quot;&amp;lt;%GetLabel('Processed')%&amp;gt;: &quot;  + (counter+1) + &quot; / &quot; + countlength);
                    counter++;
                    if (counter === countlength) {
                        $(&quot;#soapStatus&quot;).hide();
                        ajaxCompleted(html);
                        RefreshWindow();
                    }
                    return html;
                });
            });
        } catch (ex) {
            console.log('&amp;lt;%GetLabel(&quot;Efficy Error&quot;, type=&quot;jstext&quot;)%&amp;gt;: function processProjects(). &amp;lt;%GetLabel(&quot;Message:&quot;, type=&quot;jstext&quot;)%&amp;gt;\n' + ex.message);
        }
    }

    function ajaxCompleted(soapResult) {
        if (! processAjaxReturn) return;
        var resultArray;
        $('#waitSend').addClass('hide');
        soapResult = soapResult || $('#soapStatus').html();
        try {
            resultArray = soapResult.split('##_##');
            if (+resultArray[0] === 0)
                alert('&amp;lt;%GetLabel(&quot;Error while processing the projects&quot;, type=&quot;jstext&quot;)%&amp;gt;: ' + resultArray[1]);
            else
                alert('&amp;lt;%GetLabel(&quot;Projects processed!&quot;, type=&quot;jstext&quot;)%&amp;gt;');
        }
        catch(ex) {
            throw new Error('&amp;lt;%GetLabel(&quot;Error while reading the response&quot;, type=&quot;jstext&quot;)%&amp;gt;: ' + ex.message + '; request: ' + soapResult);
        }
        processAjaxReturn = false;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Has someone an idea on how I could make this process so that Efficy isn't freezing anymore?&lt;/p&gt;

&lt;p&gt;Best regards,&lt;br&gt;
Jeroen&lt;/p&gt;
</description>
<category>Efficy/ Client side</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=2375/asynchronous-processing-creation-invoices-without-freezing</guid>
<pubDate>Thu, 16 Mar 2017 14:57:06 +0000</pubDate>
</item>
</channel>
</rss>