Global Constants and Rules – Configure once, use every day!

Facebooktwitterpinterestlinkedinmail
Applies to version 2019.1; author: Kamil Nędza

1. Introduction

When working everyday in WEBCON BPS environment it’s a good idea to spend a while on configuring a group of universal constants and global rules. Time spent on creating them will be a good investment as more processes will be created in the future. This article presents a couple of real-life usage examples of:

  • Global constants
  • Global business rules
  • Global form rules

2. Global constants

Below are some ideas for universal usage of global constants.

2.1. Mail prefix

If you send e-mail notifications to users it’s worth to add a global constant to the e-mail subject. This global constant will inform users that the received e-mail does not come from the production environment. To do that you can use a global constant which should be added to the e-mail subject. For example, the constant will return „[TEST MAIL]” for DEV and TEST environments. For PROD environment the constant will not return anything. Constant can be used in global e-mail template and in the action of sending a configurable e-mail.

 

Przykład konfiguracji stałej zwracającej prefix dla tytułu maila
An example of constant configuration which returns prefix in the e-mail subject

 

E-mail subject configuration example can look as following:

 

Przykład konfiguracji akcji wysyłki konfigurowalnego maila
Example of configuration of action which sends a custom e-mail

2.2. Type of environment

It is a good idea to create a global constant which will return the type of the current installation. It can be used to manage workflows and to configure action execution. You don’t want to send an e-mail to the management from the testing environment at UAT tests? Do you want to add privileges to an additional tester group during tests? Now it’s simple – just add a proper condition on action execution.

 

Przykład konfiguracji stałej zwracającej rodzaj środowiska
Example of constant configuration which returns the type of the environment

2.3. SharePoint group ID

For SharePoint groups which are used in multiple processes (for example IT administrators group, tester group) it is a good idea to store the ID of this group as a global constant. In the next paragraphs you will be presented with how this kind of constant can be used.

 

Przykład konfiguracji stałej zwracającej ID grupy SharePoint BPS_WEBCON_ADMIN
Configuration example of a constant returning ID of SharePoint BPS_WEBCON_ADMIN group

2.4. Website address

Another global constant which is worth preparing is a basic website address. It can be used to create URL addresses for links, action configuration or be used in preinstalled SQL functions (for example dbo.isUserInSPGroup).

Przykład konfiguracji stałej zwracającej adres witryny
Configuration example of a constant which returns website address

2.5. Simple JavaScript functions – service work

Within process constant you can define also a JavaScript function which then will be executed on the workflow. Here is an example of JavaScript function which after opening the form will display user a prompt about undergoing service and then redirect him to the main website.

Przykład konfiguracji stałej zawierającej kod JavaScript
Example of constant configuration with JavaScript code

 

The constant needs to be placed in the section of rules executed on page load.

 

Przykład konfiguracji zachowania formularza
Example of form behavior configuration

On the screenshot below you can see the form in action. After clicking OK the user will be redirected to WEBCON BPS main page.

 

Formularz po otwarciu w przeglądarce
Form after opening it in the browser

 

3. Business rules

Here you can see a couple of examples of business rules which will enhance your everyday work. Just remember that in case of returning boolean data type, you don’t have to explicitly return true or false. The condition itself will do. Two business rules seen below are equal:

 

Obie reguły zwracają ten sam rezultat

Obie reguły zwracają ten sam rezultat
Both rules return the same result

3.1. IsProd

Here’s another simple example of a rule which returns information whether current environment is a production one. For example the rule can be used during configuration of action execution conditions (integration with external systems, sending configurable e-mails, etc.). This rule uses a global constant which was previously introduced in this article.

 

Konfiguracja reguły biznesowej IsProd
IsProd business rule configuration

3.2. Calculating currency exchange rate to PLN

If you need to frequently calculate currency exchange rate in a number of processes it’s worth to prepare a dedicated global business rule. On screenshots below you can see an example of this type of action configuration. Remember, for the rule to work flawlessly, you need to turn on and start currency exchange rate synchronization in the system settings.

 

Konfiguracja reguły biznesowej służącej do przeliczania walut na PLN
Configuration of business rule which is used to calculate currencies to PLN

On the right side of the screenshot above is a tab with parameters. Rule will use three parameters in the SQL query. Parameters allow to invoke the configured rule in many places with different data which makes it reusable.

 

Zapytanie SQL służące do wyliczenia kwoty w PLN na konkretny dzień
SQL query used to calculate amount of money in PLN for a specific day

 

Below you can see an example of invoking a rule and its result. In real-life usage, as parameters provide variables returning values from the workflow form.

 

 

 

Rezultat przetestowania utworzonej reguły biznesowej
Results of testing of the business rule

3.3. Existence of an attachment on the form

One of the most common actions in the workflow is one which verifies existence of an attachment on the workflow element. It comes at no surprise that its important to optimize configuration process of this action. Below you can see business rule configuration which verifies if there is an attachment on the current workflow element. This rule is very universal, however the author encourages to experiment and broaden business rules with new functions like indicating a specific file extension (ATT_FileType column).

 

Konfiguracja reguły biznesowej służącej do weryfikacji istnienia załącznika
Configuration of business rule which is used to verify the existence of the attachment
Zapytanie SQL służące do weryfikacji istnienia załącznika
SQL query used to verify existence of the attachment

3.4. Downloading all SharePoint group users

Sometimes it is needed to download all users from a specific SharePoint group. This is another case in which you can use a business rule. Below is an example of business rule configuration which returns list of all SharePoint group users.

Konfiguracja reguły biznesowej służącej do pobrania użytkowników grupy SharePoint
Business rule configuration used to download SharePoint group users

 

Zapytanie SQL służące do pobrania użytkowników grupy SharePoint
SQL query used to download SharePoint group users

 

 

Rezultat przetestowania utworzonej reguły biznesowej
Result of testing the business rule

3.5. Using working days calendar

After configuring working days calendar (which is described in detail here: http://howto.webcon.com/working-days-calendar-in-webcon-bps/) it’s a good idea to prepare rules which will return information you need. For example those can be rules returning information if a specific date is a working day or how many working days are between the provided date range.

Let’s start with a rule returning information about working day:

 

Konfiguracja reguły biznesowej służącej do weryfikacji czy wskazana data jest dniem roboczym
Configuration of business rule which is used to verify if provided data is a working day

 

Zapytanie SQL służące weryfikujące czy dany dzień jest dniem roboczym
SQL query verifying if it’s a working day

 

Rezultat przetestowania utworzonej reguły biznesowej
Testing result of this business rule

 

In workflows which need the number of working days (for example absence request process) it’s vital to have a rule prepared just for that. Here is an example of a rule which returns number of working days in the specified date range. If the date of the beginning and the end is the same, the rule will return 1 or 0, depending if this day is a working one or not.

Konfiguracja reguły biznesowej służącej do wyliczenia ilości dni roboczych
Configuration of business rule used to count working days

 

Zapytanie SQL zliczające dni robocze w podanym zakresie dat
SQL query which counts working days in the provided data range

 

Here are two examples of testing results of the business rule. In Poland the New year’s day is a day off so in the presented time frame there is only one working day – 2nd of January 2019.

Rezultat przetestowania utworzonej reguły biznesowej
Result of testing the created business rule

 

Of course there is nothing wrong with using other business rules as parameters of the global rule. Here is an example of testing the rule which returns number of working days in the next month from today. Test happened on the 2nd of April and the 22nd of April and the 1st of May are days off.

 

Rezultat przetestowania utworzonej reguły biznesowej
Results of testing the business rule

 

Author suggests that you can create more rules connected with the working days calendar. You can also use rule which returns the closest working day after X working days from a selected date.

 

4. Form rules

WEBCON BPS can define global form rules. Simple examples which can help with creating processes on a day-to-day basis are presented below.

 

4.1. Conditional verification of comment entering

Comment verification can be forced by a single checkbox placed in the path configuration. But what if it’s needed to connect the necessity of entering the comment with the value on the form? To do that you can create a global form rule which will return information whether the comment was filled in.

Caution: Described functionality is supported only on classic form.

 

Konfiguracja reguły formularza do weryfikacji uzupełnienia komentarza
Configuration of the form rule which verifies filling in the comment

 

Such a rule can be used for example on a transition path. Invoking example can be seen below.

In this specific case if the request is denied and the comment is not written, a prompt will be displayed and the form will remain in the same step. In other case the instance will go through the path to the next step.

 

Przykład użycia reguły formularza IsCommented
Example of usage of IsCommented form rule

 

Zachowanie formularza przy przejściu ścieżką przejścia odrzuconego wniosku bez uzupełnionego komentarza
Form behavior while going through a path of a rejected request without comment filled in

4.2. Distinguishing the form field

Within form rules it’s possible to define form field formatting which will be visible in all processes. This standardized method helps to draw user’s attention to key data on the form. Below is an example of universal form rules which will use a proper style for the passed form field parameter.

 

Konfiguracja reguły formularza dla pozytywnego wariantu
Form rule configuration for the positive response

 

Konfiguracja reguły formularza dla negatywnego wariantu
Form rule configuration for the negative response

 

Two form rules are defined above, both for positive and negative response. Change of form field’s background color tells us which response was given.

Below is an example of such a form rule. If the request was accepted, form field background will be green, if denied – red.

 

Przykład użycia reguły formularza
Example of usage of a form rule

 

Efekt gdy nie dokonano akceptacji
Efekt gdy nie dokonano akceptacji

 

Efekt dla akceptacji pozytywnej
Positive response

 

Efekt dla braku akceptacji
Negative response

 

5. Summary

Global constants and global rules are tools of great magnitude for everyday work with WEBCON BPS. Examples mentioned above are only the tip of an iceberg. We would like to know what are your ideas for everyday work optimization in WEBCON Designer Studio. Share them in the comments!

Leave a Reply

Your email address will not be published. Required fields are marked *