Dynamic conditions migration

Dynamic conditions migration when upgrading to TAS 5.3

In TAS 5.3, dynamic conditions were changed mainly for better performance, but also for better maintenance in the future and for security reasons.

There is no need to edit scripts on dynamic lines, everything still works as before.
The main change is that as of TAS 5.3, you can no longer use the this task context reference in dynamic conditions. You need to use the getCurrentTask() function.

Adjusting dynamic conditions

Essentially, you just need to add const currentTask = getCurrentTask(); to the beginning of the dynamic conditions, and then use ctr+f to search for "this" and then "self" and replace according to the following points.

  1. Remove var self = this;
    There is no need to use it, as self is no longer referenced anywhere.
  2. currentTask needs to be redefined at the beginning of the task as:
//Na začátek podmínek přidat
const currentTask = getCurrentTask();
  1. Within this.references, I can either use the new getReferences() function or use references within currentTask.
//Starý zápis
this.references

//Nový zápis
const references = getReferences();
//Nebo
currentTask.references

Likewise, for self.references I will use currentTask:

//Starý zápis
self.references['additionalInfo'].setValue("");

//Nový zápis
currentTask.references['additionalInfo'].setValue("");
  1. Within this.language, I can either use the new getLanguage() function or use references within currentTask.
//Starý zápis
this.language
//nebo
self.language

//Nový zápis
const language = getLanguage();
//Nebo
currentTask.language
  1. Within this.state.items I can use either:
//Starý zápis
this.state.items

//Nový zápis
currentTask.items
//Nebo
currentTask.state.items
  1. Removing this. from the getDynTable() function
//Varianta 1

//Starý zápis//
this.getDynTable(39, 1)

//Nový zápis - odstranění this//
getDynTable(39, 1)

//Varianta 2

//Starý zápis//
this.dynTable[39]

//Nový zápis - odstranění this//
dynTable[39]

Alternatively, if I have self.dyntable :

//Starý zápis//
self.dynTable[_nazevDynTable1]

//Nový zápis - odstranění self//
dynTable[_nazevDynTable1]
  1. Replacing this.props.parent.state with currentTask
//Starý zápis
create_pdf_preview(true, this.props.parent.state.iprocId);

//Nový zápis
create_pdf_preview(true, currentTask.iprocId);
  1. Changing ivar_lov using varDefOn
//Starý zápis
const lovsVar = _.find(this.state.items, 'tvar_name', 'lovs');

//Nový zápis - Nově je potřeba brát z immutableItems
const lovsVar = _.find(currentTask.immutableItems, 'tvar_name', 'lovs');
  1. Replacing self. when using items
//Starý zápis
self['items']

//Nový zápis
currentTask['items']
  1. For dynamic rows, you need to modify the call like this
//Starý zápis
this.currentTask.taskInfo.headerCode

//Nový zápis
this.currentTask.state.taskInfo.headerCode
  1. Getting an array of names of selected values ​​in a dynamic multichoice table variable
//Starý zápis
const multiDTTitles = self.references['multiDT'].state.rightValues;

//Nový zápis
const multiDTArray = currentTask.references['multiDT'].getValueObjArray();
const multiDTTitles = multiDTArray.map(multiDTArray => multiDTArray.title);

Shortened version of migration

A shortened version without explanation suitable for easy copying is here:

this.getDynTable(39, 1) -> getDynTable(39, 1)
this.dynTable[39] -> dynTable[39]
self.dynTable[_nazevDynTable1] -> dynTable[_nazevDynTable1]

currentTask -> const currentTask = getCurrentTask();

this.references -> getReferences() nebo currentTask.references
this.language -> getLanguage() nebo currentTask.language
this.state.items -> currentTask.items nebo currentTask.state.items

self['items'] -> currentTask['items']
self.references['additionalInfo'].setValue("") -> currentTask.references['additionalInfo'].setValue("")

create_pdf_preview(true, this.props.parent.state.iprocId) -> create_pdf_preview(true, currentTask.iprocId)

this.props.parent.state.iprocId -> currentTask.iprocId

//Změna ivar_lov pomocí varDefOn
//Původně
const lovsVar = _.find(this.state.items, 'tvar_name', 'lovs');
const lovsClone = _.clone(lovsVar, true);
const filtered = _.filter(lovsClone.ivar_lov …

//Nově je potřeba brát z immutableItems
const lovsVar = _.find(currentTask.state.items, 'tvar_name', 'lovs');
const filtered = _.filter(lovsVar.ivar_lov …

function getCurrentTask();

All values ​​that can be obtained in dynamic conditions using getCurrentTask()

getCurrentTask
return {
id,
iprocId,
language,
refs,
references,
items,
processVars,
immutableItems,
taskHeading,
taskHeadingTranslated,
state: {
buttonsStatus,
taskInfo,
items,
processVars,
immutableItems,
},
};

Anna Gernát Updated by Anna Gernát

PDF printing adjustment

Contact

Syca (opens in a new tab)

Powered by HelpDocs (opens in a new tab)