Why Funcmode is important

I recently had a question where the developer had built a process which included a loop.  Within that loop, there was a custom function which determined which level of approver was required before applying processing logic, something similar to this:

The problem was that when the “Do Something” step was being executed, it appeared that the “Find Approval Level” step was always jumping two levels – the first and third approvers were being found, but never the second or fourth.  So, there must have been something wrong in the “Find Approval Level” step if it was always jumping two levels, right?

Wrong!  The problem was that the loop activities in the process hadn’t been defined properly, and the code hadn’t been written correctly in a very basic manner.

The Workflow activities should have had the “On Revisit” flag set correctly for the activities that were in the loop.  The standard is to have it set to “Reset” which will re-run the activities in CANCEL mode before re-running the loop in RUN mode.  Instead, the activities should have had the flag set to “Loop”:

If the flag is set to “Ignore”, then the activity would only be executed once – which means that you would end up in a perpetual loop in this example, since the “More Required?” step would always return “Yes” unless there was only one approval level.

The basic change to the code is to check what the FUNCMODE is before doing any further processing.  If the code was written so that the search for the approver only happened during RUN mode, then the process wouldn’t appear to skip a level.  Unless there is specific code to undo an execution, then I always include a check at the start of my activities which says that if FUNCMODE does not equal WF_ENGINE.ENG_RUN (the externalized constant for RUN mode), then simply RETURN to the Workflow Engine.  This saves processing time and avoids problems like the one we see here.

By continuing to use the site, you agree to the use of cookies. more information

In common with almost all professionally run websites, this website logs the IP address of each visitor in order to keep it running reliably. This is also essential for protecting the website and its visitors from malicious attacks, including infection with malware.

This website provides information as a service to visitors such as yourself, and to do this reliably and efficiently, it sometimes places small amounts of information on your computer or device (e.g. mobile phone). This includes small files known as cookies. The cookies stored by this website cannot be used to identify you personally.

We use cookies to understand what pages and information visitors find useful, and to detect problems such as broken links, or pages which are taking a long time to load.

We sometimes use cookies to remember a choice you make on one page, when you have moved to another page if that information can be used to make the website work better. For example:
- avoiding the need to ask for the same information several times during a session (e.g. when filling in forms), or
- remembering that you have logged in, so that you don’t have to re-enter your username and password on every page.

You can prevent the setting of cookies by adjusting the settings on your browser (see your browser Help for how to do this). Be aware that disabling cookies will affect the functionality of this and many other websites that you visit.

Close