Is having 'Invoke workflow' actions inside Excel Process Scope a bad practice?

Here is my scenario:

I have multiple different workflows that each process different sheets of an excel file. The flows for different sheets vary slightly, but there are a lot of parts that are identical in each workflow.

As best practices, my instinct was to create separate workflows for those identical parts, so that I can reuse my code instead of copying and pasting it everywhere.

However, in order to do this, I will need to have an ‘Invoke workflow’ activity inside the ‘Excel process scope’ and ‘Process excel file’ activities. Those invoked workflows will need to have another ‘Excel process scope’ and ‘Process excel file’ activity, where the ‘Excel file’ input argument of the ‘Process excel file’ activity will be the same in the ‘parent’ workflow and the ‘invoked’ workflow. I will set the ‘Keep excel file open’ to true in the invoked workflow, so it won’t close and reopen unnecessarily.

However I still worry that having so many unnecessary ‘Excel process scope’ and ‘Process excel file’ activities will negatively effect the performances, especially since a lot of those reusable parts are very small and simple and I’m not sure it’s worth separating in a different workflow.

On the other hand, it’s very impractical to copy those parts all workflows, since making changes in all of them is a nightmare and the code is very messy.

What would be the ‘best practice’ in this situation? Thank you so much for your input!

-M

Hey @M_Kr

If you are re-using it just then move the invoke workflow outside of the Excel scope as you already have the Excel process scope inside the workflow with session object as input.

Thanks
#nK

Hi @Nithinkrishna

Can you please elaborate on this further? How do I pass the session as input? Also, how will this help me optimise the process?

Thanks!
#M

Hey @M_Kr

It can be just passed as an in argument and used in the activity further

You may not keep the Excel scope open for longer and for unnecessary stuff.

Hope this helps.

Thanks
#nK

Thank you so much for this information, I had no idea that keeping the Excel process scope longer reflects negatively on the performances.

In this case, if for example I have some ‘excel’ activities, then I have some non-excel activities, then some excel activities again, it is better to have one process scope for the first excel activities, then put the non-excel activities out of the scope, then open a new process scope for the second excel activities, rather than putting everything in one process scope, correct?

I figured that opening a new process scope will slow down the process and reflect negatively on the performances, so I put everything in one excel process scope, even the non-excel activities in between.

Also, when you say ‘pass the session as input’, are you referring to the ‘Excel’ variable from the ‘Use excel file’ activity? If so, how do I pass it, since I don’t have the variable out of the scope of that activity in order to send it in the ‘Invoke Workflow’

Thank you for clearing some things up for me!

#M

You said it right :fire:

You are right here as well, But not yet available in the modern scope but available in classic activity scope as of now. Hopefully soon.