Getting "Message Execution Timeout Expired" when I add my simple query to the flow
Application Type
Traditional Web
Service Studio Version
11.14.7 (Build 58100)

I am adding a advanced sql query wdiget that multiplies and sums up the multiplied values from three table columns to a loop. I then append the result to a local variable (structure). I don't know why but it keeps timing out. When I remove the advanced SQL query widget, it finishes without any issues. I believe my query is simple and not that complex and only spits out one record. Kindly help me out with this.

The error message:

The flow:

The SQL Query I'm adding:


The SQL query I'm looping through:


The Append:


The Append without my query (does not time out when it goes through this flow):


Lets start from the top and see if we can fix your time out.

There are some insufficient pieces of code in your flow:

- Why is the first SQL an advanced sql? You also output 8 full entities. By making it an aggregate, Outsystems will only output the fields needed.

- If you expect only 1 record, please set the max records to 1.

- The advanced sql that gives back a sum: just to make it more readable: put it in a separate server action or function.

Where does this code run? is it inside a bpt process, a timer or on the screen?

Hi Stefano. Thank you for responding. My answers to your questions are in red.

- Why is the first SQL an advanced sql? You also output 8 full entities. By making it an aggregate, Outsystems will only output the fields needed.

-The first SQL - GetAccountsById was built by the previous developers. This project was just handed over to me. I did not change it because it worked fine and didn't time out before (as shown in flow The Append without my query ). 

But whenever I add my own change -> advance sql - CalculateCoinValuatedTotal, it times out.

- If you expect only 1 record, please set the max records to 1.

- I tried your suggestion and I set the max record to 1 for CalculateCoinValuatedTotal since I expected 1 record. It still times out.

Where does this code run? is it inside a bpt process, a timer or on the screen?

- This server action code is ran from another server action that is called by a process

I would still recommend changing that sql, but you are explicitly saying this second sql with the sum is the problem.

Can you put that sql into a separate server action and call it from a screen, then debug it so you can see how long it takes?


Be aware that everything inside that automatic activity must be done within 3 minutes or OS will do a time out.

I would still recommend changing that sql, but you are explicitly saying this second sql with the sum is the problem.

-Yes I believe the sql with the sum is the problem because it only times out when the flow runs through it. But I'm curious, does the error stack that I sent a picture of identify what causes the time out? I am not good at reading error stacks from Outsystems. Additionally, what sql would do you recommend that I change? The one with the sum or the GetAccountsById? Because if it's the one with the sum, I originally created an aggregate that does the same and it also still timed out. If you're suggesting that I change the GetAccountsById sql, I would ask you how. I am honestly not sure how to turn that into an aggregate. It looks massive and I'm afraid I'd just break another thing in the code since I did not originally make it. 

Can you put that sql into a separate server action and call it from a screen, then debug it so you can see how long it takes?

- I tried this and debugged the sql with the sum(CalculateCoinValuatedTotal). It took like 2-3 seconds.

Be aware that everything inside that automatic activity must be done within 3 minutes or OS will do a time out.

-I was not aware of this. What's weird is when the code does not run through the sum sql (CalculateCoinValuatedTotal), I tried to time it and the run took more than 3 minutes. It was like 4-5 minutes but it did not time out.

If the sql takes only about 2-3 seconds then it depends howmany records are in the list. If you have about 100 records it means it will take about 300 seconds and that means you will get a time out due to the time out of the automatic activity.


Is it possible you try to put this code in a timer? you can set the time out of the timer to 10 minutes.

another options is to limit the max records of the first sql, to see if you still get the time out. you could limit it to 10 records to start..



Can you give a bit more information on those 3 entities you have inside that sql?

The masterbalance, the cryptocurrency and especially the valuation entity?

Here's a view of the three entities:

I just simply take the sum of CryptopiaMasterBalance}.[Total] multiplied by {CoinValuation}.[CoinValue]. I use the CryptoCurrencyId to connect the two.

This is probably what it looks like in aggregate form:


Does the  coinvaluation entity have a 1 on 1 relation with the cryptocurrency? If not you have a problem.

The relationship is one to many. 

How is that a problem? What should I do to resolve it?

Which coinvalue should it sum up to? 

You now have a totalvalue that could have 20 coinvalues. What will the sum() do?

You might want to have IsLatest = true in the where clause.

Sum just sums up the 20 coin values that I get. IsLatest is used in a different context. There are also use-cases that I'd have to get those that are not IsLatest

if you would remoce the sum inyour sql, you would get a record for every coinvalue.

so you could have:

coinA, total 100, coinvalue 1

coinA, total 100, coinvalue 2

coinA, total 100, coinvalue3


now if that would sum up you would get 600. i am not sure if thats what you want.



What I wanted was the sum of the encircled in the picture. So I just right-clicked and clicked "SUM". Is that not correct?


Is that maybe the reason why it's timing out?


i still think its your automatic activity that is timing out, and that would be because your process is taking more than 3 minuten. I advise you to create a simple export, with only a few loops, so you can see if that goes well.


But if thats what you want, the sum, then your query seems ok. I just cant understand why you would want a sum of all snapshots. with this i mean:

you have a total amount of 100 ltc. The value changes a lot and this is what you register in your Valuation entity. Why would you ever do a sum of that total (this is an endvalue) and all the values it has ever had?


if i had 1 bitcoin and registered all valuation on a daily basis the sum would be something like 1 * 37000 * 365 (days). I have a background in finance and i just cant figure out why someone would want to calculate this.




i still think its your automatic activity that is timing out, and that would be because your process is taking more than 3 minuten. I advise you to create a simple export, with only a few loops, so you can see if that goes well.

- I tried creating a simple export without involving a lot of loops. I tried just trying an export involving the CryptopiaMasterBalance table and it also times out. It's really frustrating.


But if thats what you want, the sum, then your query seems ok. I just cant understand why you would want a sum of all snapshots. with this i mean:

you have a total amount of 100 ltc. The value changes a lot and this is what you register in your Valuation entity. Why would you ever do a sum of that total (this is an endvalue) and all the values it has ever had?

- What I was told is that they want to pick a certain valuation that they uploaded and from that calculate the coin value (Total Balance of that coin multiplied by the coin value in the coin valuation) and then get the sum to be exported in the csv as TotalUSD. They want a report of what would be the sum if they pick a coin valuation. I asked them and basically said "Ok, so I think to get this I need to multiply the totalmasterbalance with the coin value and get the sum? Is that right?". They told me yes, it was right. I didn't really think a lot about it. I'm just targeting getting the result in the export. 


I appreciate your attempt to help.

if you want to pick a certain coin valuation, then you should include that in  a where clause somewhere in the sql.  so this will result in a wrong output and it could be a reason your sql fails: if that sum is getting to high. But then you don't get a time out.


To be sure its the automatic activity that is failing you can do 2 things: 

- Try to get your loop small (1 or 2 loops) 

- Put the code in a timer.


Could you try one of the 2 to see if this removes your time out?

After that we can fix your sum issue.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.