Business logic

From Resco's Wiki
Revision as of 08:31, 23 July 2021 by Jzambor (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Wikipedia logo
Wikipedia has an article on a similar subject:
Resco Academy
Resco Academy has a course on a similar subject:
Business logic
Client-side

Server-side

Business logic is a part of a program or application, essentially a set of business rules and workflows that direct the interaction between user interface and data. The Resco platform comes with a strong focus on mobility and comes with powerful options for client-side business logic. On the server side, Dynamics and Salesforce come with their own business logic; and so does Resco Cloud.

Examples

Here are some simple examples of what we understand as business logic in Resco Mobile CRM:

  • Validate email address, postal code, telephone number
  • Calculate the duration of an event (actual end – actual start)
  • Hide a field or disable it, depending on a condition
  • Populate fields on a child entity based on the parent
  • Modify an order to add a special discount
  • Find out how many appointments are associated to an account

Client-side business logic (Resco Mobile CRM)

Resco mobile apps come with several levels of business logic.

  • Built-in / hard-coded
  • Reused server-side logic
  • No-code logic using rules (Form, View, Calendar, Map, …)
  • JavaScript logic using Resco JavaScript Bridge

Rules

Rules are scripts that run directly in the mobile application. They offer a way for setting up business logic using Woodford. Rules can be placed on multiple user interface components:

We are continuously adding rules support to UI components. See Rules editor for more information about rules.

Scripting language

Sample rule

Rules are formed in a simple scripting language. Essentially, you combine conditions and steps.

Conditions
  • If...
  • Then...
  • Else...
Steps
  • Hide fields
  • Set read-only
  • Assignment
  • Set GPS position
  • Say text
  • Set a variable
  • Load a fetch

You don't write scripts, you build them using buttons and selecting values from a drop-down menu. Use the dot notation to work with entity fields or object properties.

Objects in rules

Rules allow you to evaluate and modify parameters of various objects:

  • Entity – edit/create/delete records
  • Form – modify what's displayed on a form
  • Tabs – modify all the tabs of a form
  • Variables / shared variables – Save a value as a variable to use later in a rule, display, or use in a different rule
  • Configuration – currently logged-in user, URL, online/offline status, etc.
  • Relationship – determine whether a form is opened via associated view
  • Specialties

Form rules

Form rules describe sequences of steps that are executed on form-related events. They allow you to for example to customize edit form user interface (hide or disable fields, assign values, etc.). Here are some of the events available for forms:

On Load
These rules are checked when you open a form. You can use these rules for example to apply custom format to certain records.
On Change
These rules are checked when you open a form or modify any field. Example: simple form validation.
On Save
These rules are checked when you save a record. For example, saving a record can automatically also update a field in a parent record.
On Can Execute
Define when a form command is available for the user.
On Execute
Define the actions that the command performs.

View rules

These are some of the events that trigger rule execution for views.

Row Script
Define conditions when a specific row design should be used.
On Save, On Change
These events are used in conjunction with editable lists, where they play a similar role as on the form.
Button Click
Executed when a row button is clicked.
Cell Click
Executed when an editable or clickable cell is clicked.

JavaScript

Resco JavaScript Bridge, or JSBridge.js, is a component provided by Resco that allows the scripts in the HTML frame to interact with Resco mobile apps. You can interact with the user interface, with data, and perform additional actions. Script files need to be included in the project using the Offline HTML section of Woodford.

Rules and JavaScript can even be combined, see Execute JavaScript from rules for more information.

Server-side business logic (Resco Cloud)

For some business logic scenarios, client-side implementation on the mobile device is not suitable. For these cases, we recommend using processes and plugins running on the server instead. Each backend server has its own specifics. On Resco Cloud, server-side business logic is managed using the Admin Console under Processes. The following options are available:

  • Processes: low-code option using a scripting language similar to the one used in the Rules editor.
  • Plugins: write custom C# code that can be launched from the processes.

See also