Серверный скрипт для генерации цвета поля state

//Generator of colors for state in table 
const color = new SimpleRecord('sys_style_rule_column');
let relation = {
    '(state=-2)':'red',
    '(state=0)':'purple',
    '(state=10)':'dark',
    '(state=2)':'yellow',
    '(state=4)':'blue',
    '(state=8)':'orange',
    '(state=3^ORstate=6)':'gray',
    '(state=7)':'green',
    '(state=-1)':'aqua'
  }
for (const [key, value] of Object.entries(relation)) {
    color.table_id = '167895371828280792'; // sys_id колонки
    color.column_id = '155931135900001086';// sys_id таблицы
    color.color = value // Цвет
    color.condition = key // Условие
    color.insert()
    const insertedColorID = color.insert();
   if (insertedColorID == 0) {
  ss.info(color.getErrors());
}
ss.info(`/record/sys_style_rule_column/${insertedColorID}`);
 }
2 лайка