- Version 5.7 – built-in sys. functions
- Finding where global scripts are used in calculations
- Finding a specific function or text in global scripts
- Finding a specific function or text in calculations
- Finding a specific function or text in dynamic conditions and dynamic rows
- Finding unsupported functions (lodash and other discontinued functions)
- Automatic replacement of unsupported Lodash functions
- Versions 5.17 – 5.19 – Template Validation plugin 1.x
Using validation functions
- Version 5.7 – built-in sys. functions
- Finding where global scripts are used in calculations
- Finding a specific function or text in global scripts
- Finding a specific function or text in calculations
- Finding a specific function or text in dynamic conditions and dynamic rows
- Finding unsupported functions (lodash and other discontinued functions)
- Automatic replacement of unsupported Lodash functions
- Versions 5.17 – 5.19 – Template Validation plugin 1.x
To make the transition from older system versions easier, you can use the validation and search functions that run in Administration → Service Console. The functions scan calculations, dynamic conditions, dynamic rows, print templates (Case Overview) and global scripts, look for unsupported code, and can fix some of the findings automatically.
How the functions are called depends on the TAS version:
|
TAS version |
Where the functions live |
Call prefix |
|
5.7 (from 5.7.33) |
Built into the system |
|
|
Template Validation plugin, version 1.x |
|
validation object does not exist in the Service Console.Version 5.7 – built-in sys. functions
Available from version 5.7.33.
Finding where global scripts are used in calculations
To find where a specific global script is used in calculations, use the functions below.
sys.findScriptImportstInCalculations();
With an empty first parameter, the function searches all templates on the environment.
sys.findScriptImportstInCalculations(1626);
With a template ID, the function searches and returns tasks from that template only.
From the result, you can click through directly to the specific template or task.
Finding a specific function or text in global scripts
sys.findInScripts('result.data.split');
Finds where result.data.split is used.
You can also use a regular expression:
sys.findInScripts(/\bvar\s+approverArray\s*=\s*JSON\.parse\s*\(/);
sys.findInScripts() function.Finding a specific function or text in calculations
sys.findInCalculations('sortedTaskActual', 27);
Finds where sortedTaskActual is used in the template with ID 27.
sys.findInCalculations('sortedTaskActual');
Without a template ID, it finds where sortedTaskActual is used in all templates.
You can also use a regular expression:
sys.findInCalculations(/\bvar\s+approverArray\s*=\s*JSON\.parse\s*\(/);
sys.findInCalculations() function.Finding a specific function or text in dynamic conditions and dynamic rows
sys.findInConditions('test');
Finds where the string test is used in all dynamic conditions and dynamic rows (script).
Finding unsupported functions (lodash and other discontinued functions)
A detailed description of the lodash upgrade can be found here. This check is already available in version 5.3.
sys.validateTemplate(1626);
Scans a specific template and returns all occurrences of unsupported functions. It scans:
- calculations,
- dynamic conditions,
- dynamic rows,
- print templates.
sys.fixTemplateIssues(); function.sys.validateTemplates();
Scans all templates in the same way as sys.validateTemplate().
sys.validateGlobalScripts();
Checks global scripts (Calculations, CO React, CO).
Automatic replacement of unsupported Lodash functions
sys.replaceDeprecatedLodashUsage();
With an empty parameter, the replacement runs in all templates. With a template ID, it runs in that template only. It replaces code in calculations, dynamic conditions, dynamic rows and scripts. It also automatically rewrites the unsupported _.find syntax (see Lodash Upgrade).
Versions 5.17 – 5.19 – Template Validation plugin 1.x
The functions have moved to the Template Validation plugin. Their names and parameters are the same as in version 5.7, but they are called through validation. instead of sys., for example:
validation.validateTemplate(1626);
validation.findInCalculations('sortedTaskActual', 27);
validation.replaceDeprecatedLodashUsage();
All functions from version 5.7 work the same way. Plugin 1.x also adds:
|
Function |
Description |
|
|
Full-text search across all templates. |
|
|
Full-text search in a single template. |
|
|
Finds where a specific function is used in all templates. |
|
|
Finds where a specific function is used in a single template. |
|
|
Finds where a specific function is used in global scripts. |
|
|
From version 5.18.2. Checks all templates and global scripts for deprecated MUI Grid v6 props ( |
|
|
From version 5.18.2. Fixes deprecated MUI Grid props. Without a parameter, it runs in all templates and global scripts. |
|
|
From version 5.18.14. Lists calculations and global scripts that need to be retranspiled. Without a parameter, it checks all templates and scripts. To retranspile, use |
Pre-upgrade check – validation.checkMigration()
validation.checkMigration();
Scans the whole system, including global scripts, and returns a summary table of findings grouped by rule. Each rule shows its severity, the number of occurrences, and whether it can be fixed automatically.
validation.checkMigration(1626);
Checks only the template with ID 1626.
Finding severity:
|
Severity |
Meaning |
|
|
Does not work now – the function or API no longer exists in the system. |
|
|
The code runs, but behaves incorrectly or the data is inconsistent. |
|
|
Still works, but its removal is scheduled. The report shows the version until which it will keep working. After upgrading to that version, the finding automatically changes to |
|
|
Cosmetic finding. |
Rule detail – validation.checkRule()
The rule ID (ruleId) is shown in the validation.checkMigration() report.
validation.checkRule('lodash.pluck');
validation.checkRule('lodash.pluck', 1626);
Lists every place where the rule fired, with a link to the template, task or script.
Search – validation.find()
Replaces all earlier search functions (findInScripts, findInCalculations, findInConditions, findTextInTemplate(s), findFunctionInTemplate(s), findFunctionInScripts).
validation.find('result.data.split');
Searches for the text in all templates and global scripts.
validation.find('sortedTaskActual', { tProcId: 27 });
Searches for the text only in the template with ID 27.
validation.find(/\bvar\s+approverArray\s*=\s*JSON\.parse\s*\(/);
The search term can also be a regular expression.
validation.find() function.Optional second parameter options:
|
Parameter |
Description |
|
|
Template ID. Without it, the whole system is searched, including global scripts. |
|
|
|
|
|
Limits the search to selected code types: |
|
|
|
validation.find('getApprovers', { mode: 'definition' }); – where the getApprovers function is defined,validation.find('getApprovers', { mode: 'call', kinds: ['taskCalculation'] }); – where it is called in calculations,validation.find('test', { kinds: ['taskCondition', 'dynamicRow'] }); – the equivalent of the former findInConditions('test').Automatic fix – validation.fix()
validation.fix('lodash.find-3arg');
validation.fix('lodash.find-3arg', 1626);
Fixes the findings of the given rule, writes the changes and lists the diff of every change. Only rules that have the fix column filled in the validation.checkMigration() report can be fixed. Each fixable rule shows the confidence of its fix:
safe– the fix is safe,review– the fix should be reviewed,bestEffort– the fix is a best guess and the result must be reviewed.
Automatically fixable rules:
|
Rule |
Fix |
|
|
Rewrites |
|
|
Converts deprecated MUI Grid v6 props to the v7 syntax in Case Overview and global scripts. Confidence |
|
|
Repairs an incorrectly stored list of imported global scripts in calculations. Confidence |
|
|
Rewrites the use of the |
review and bestEffort confidence.Global scripts used in calculations – validation.findScriptImports()
validation.findScriptImports();
validation.findScriptImports(1626);
Lists which global scripts each task calculation imports. Without a parameter, it covers all templates; with a template ID, only that template.
What the validation checks
- Unsupported Lodash functions – e.g.
_.pluck,_.where,_.findWhere,_.first,_.indexBy,_.pairs,_.padLeft,_.trimLeft,_.sortByOrderand_.findcalled with three parameters. The report always gives the replacement. - Removed API functions:
lib.storeCsvFromDms(),lib.getAresData(),lib.setList(),lib.getPublicKey(),lib.getSecret(),lib.setSecret()– replaced byvault.get(),lib.getCertificatePath()and hardcoded paths to the certificate directory – replaced bylib.getCertificate(certName),- all
curl.*functions – use AxiosApi for REST calls and FtpApi for FTP/SFTP, docx.generate()anddocx.docxTemplater()– replaced bydocxGenerator.generate(),- the POST method for
/dms/download/:idand/dms/archived/download/:id– use GET.
- Deprecated functions –
lib.dmsPdfFileToText()(replaced bylib.pdfToText()),IPROC_CASE_STATUS(replaced byproc.setCaseStatus()/proc.getCaseStatus(), orlib.changeCaseStatus()for another case). - Public file URLs under
/assets/, which are no longer supported. - Deprecated MUI Grid v6 props in Case Overview and global scripts.
- Calculations and global scripts that need retranspiling – retranspile them with
sys.retranspileCalculationsByProcessId()orsys.retranspileGlobalScripts(). - Calculations importing a global script that no longer exists.
- Invitation tasks – this task type has been removed; these tasks need to be removed or replaced.
- Historical B variables – this variable type has been removed.
Conversion table from plugin 1.x to 2.x
|
Original function (5.7 |
Plugin 2.x (from 5.20.8) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
validation.
Updated
by Frantisek Brych