Proces flow - open screen after set time or event

  • 6 January 2021
  • 3 replies
  • 89 views

Userlevel 5
Badge +12

Hi all,

I have set up the report generator, which is great. I also have an upload to Azure (developed outside of SF) which updates my Db with an online path to the file in the cloud. All is good. When a client creates a pdf (e.g. an invoice) with a task.

The following happens; 

click task → insert in Table Rpt_queue → file is made. → File is pickup by magic → uploaded to Azure → File path is inserted in an extra column in the rpt_queue. 

An update trigger fires and send the file back to the source table (e.g. invoices) AND to a table 'Document Pool’. The document pool is where we collect ALL files on this account. Invoices, reports, bills, contract, etc.  Anything generated?  → boom, in the document pool. 

So, after the task has fired, we use a process flow to open this document pool in a new tab. All good. HOWEVER, due to the time it takes to generate and handle the file, the doc.pool is not updated yet. This takes on avarage 20secs. 

Is it possible to either delay to process flow with 20seconds?  (with a loading bar if possible - this way the client will think 'oh, the file is on it's way.’ → doc. pool opens with the file in it). 

OR 

Refresh the doc.pool automatically 20secs after opening it (refresh only once)

OR 

Refresh the doc.pool when an insert is done? 

 

Any takes on this? 

Kind regards, 

 

Alex  

Mark Jongeling 3 years ago

Hi Alex,

Delaying the opening of a screen is possible by having a task run an SQL function called WAITFOR DELAY inside the process flow as an Execute task. In this task you could have a 20 second timer like this:

10 second wait - @number_of_second as parameter (int)

Very basic code as follows:

declare @i int = 0
, @i_text varchar(100)
, @percentage int = 0

select @i_text = try_cast(@i as varchar(100))
exec tsf_send_progress 'wait_for_second', @i_text, @percentage

while @number_of_second > @i
or @i > 61
begin
waitfor delay '00:00:01'

select @i = @i+1

select @percentage = 100 / @number_of_second * @i
select @i_text = try_cast(@i as varchar(100))
exec tsf_send_progress 'wait_for_second', @i_text, @percentage
end

You can of course give it a default value of 20 seonds. This way the user has to wait 20 seconds and the process flow will continue after this task ends.

 

The Software Factory also offers an Auto refresh option in the Subject screen under settings. This way the screen will refresh every X seconds, there you could set 5 seconds for example.

Refreshing the screen after the generation process is over is not possible as it is not part of the Process flow.

Hope this helps!

Kind regards,
Mark Jongeling

View original

This topic has been closed for comments

3 replies

Userlevel 7
Badge +23

Hi Alex,

Delaying the opening of a screen is possible by having a task run an SQL function called WAITFOR DELAY inside the process flow as an Execute task. In this task you could have a 20 second timer like this:

10 second wait - @number_of_second as parameter (int)

Very basic code as follows:

declare @i int = 0
, @i_text varchar(100)
, @percentage int = 0

select @i_text = try_cast(@i as varchar(100))
exec tsf_send_progress 'wait_for_second', @i_text, @percentage

while @number_of_second > @i
or @i > 61
begin
waitfor delay '00:00:01'

select @i = @i+1

select @percentage = 100 / @number_of_second * @i
select @i_text = try_cast(@i as varchar(100))
exec tsf_send_progress 'wait_for_second', @i_text, @percentage
end

You can of course give it a default value of 20 seonds. This way the user has to wait 20 seconds and the process flow will continue after this task ends.

 

The Software Factory also offers an Auto refresh option in the Subject screen under settings. This way the screen will refresh every X seconds, there you could set 5 seconds for example.

Refreshing the screen after the generation process is over is not possible as it is not part of the Process flow.

Hope this helps!

Kind regards,
Mark Jongeling

Userlevel 5
Badge +12

@Mark Jongeling  

works like a charm

Awesome work. Hopefully the client thinks the same way ;) 

Userlevel 7
Badge +23

If you have a moment in the generation of the reports that you can set a column value in a table, then you can use that value to determine of your generation process is finished. This you can use in the While loop to decide when to leave the While loop.

Now it just ends after 20 seconds in your case, but if you have a select query that can look up if the generation process is finished, then you can end the While loop earlier. If then the generation is really quick, then the client doesn't have to wait 20 seconds.

(Do keep the 20 seconds in case the generation takes longer or the While loop for some reason never ends)

And thanks for the music, I like it :wink: