User guide
Quick Start Guide
Dashboard
Overviews
Case detail (Caseoverview)
Case - event
Tasks
Case notes
Documents
User settings
Favorites
Table component
FAQ
Administrator Guide
Platform guide
Administration
Crons
Authentication and Synchronization
Mobile App Setup for Your Environment
Scheme
Dynamic tables
Archiving
Scripts
Service console
Scheduled Tasks
HR Agenda
Sequences
CSP Headers
Logs
Access Token Settings & Session Expiration
Template
Roles
Planning
Users
Organizational structure
Events
Translations
AXIOS API
Calculations & Functions
Integrations
TAS Forms
TAS Forms
Activating the module on the environment
TAS Forms - secret creation guide for Docker Swarm
Advanced Features & Tips
Partners
Product
Business Changelog
Technical Changelog
Version Upgrade Guide
Upgrading to 5.9
Upgrading to 5.3
Dynamic conditions migration
PDF printing adjustment
Editing Task Description vs Task Instructions
Transpiling forEach to a for loop
Rendering HTML on Caseoverview
Upgrading to 5.7
Lodash upgrade v4.17.x (>v5.5)
Main changes and deprecated features (v5.3 > v5.7)
Using validation functions
Differences between TAS4 and TAS5 - a complete overview
Best Practices for Upgrading from v4 to v5
Technical details
News / Important information
- All Categories /
- Administrator Guide
- Calculations & Functions
- Form condition
- Other dynamic conditions /
- Optimization of API calls on dynamic conditions
Optimization of API calls on dynamic conditions
By using cachedValue it is possible to ensure that services that are used multiple times in a form can be called only once.
cachedValue is reset when the service is to be resent - for example, when the value of a variable used in a filter changes.let cachedRow = null;
const fetchData = () => {
if (cachedRow) {
return cachedRow;
}
cachedRow = new Promise((resolve, reject) => {
return Api.request.get(`/dyn-table/TAS-configCO/values`).then(data => {
resolve(data);
}).catch(error => {
console.error('There was a problem with the fetch operation:', error);
reject(error);
});
});
return cachedRow;
}
let cachedTableDepartments = null
const fetchDepartmentsTable = (table) => {
if (cachedTableDepartments) {
return cachedTableDepartments;
}
cachedTableDepartments = new Promise((resolve, reject) => {
return Api.request.get(`/dyn-table/${table}/values?total_count=false`).then(data => {
resolve(data);
}).catch(error => {
console.error('There was a problem with the fetch operation:', error);
reject(error);
});
});
return cachedTableDepartments;
}
Use in condition:
let isCompanyRelationshipHidden = false;
let department = null;
hideVarOn('companyRelationship', () => {
if (vSync('contractDepartment') && department === vSync('contractDepartment')) return isCompanyRelationshipHidden;
department = vSync('contractDepartment')
return fetchData().then(payload => {
let {
items
} = payload;
items = items.filter(item => {
return item.dtv_index === id;
})
const dtDepartments = items[0]?.col_7;
const canRepresent = items[0]?.col_10
if (canRepresent !== 'True' || !vSync('contractDepartment')) {
isCompanyRelationshipHidden = true
return true;
}
const department = references.contractDepartment.getValue();
return fetchDepartmentsTable(dtDepartments).then(payload => {
const {
items
} = payload;
const canRepresent = items.find(item => item.dtv_index === department)?.col_2;
isCompanyRelationshipHidden = canRepresent !== 'True';
return canRepresent !== 'True'
})
})
})
Updated
by Frantisek Brych