Серверный скрипт создания рандомного сотрудника и привязанной к нему компании

let employee_company;

let company = new SimpleRecord('org_company');

let employee = new SimpleRecord('employee');

function createCompany() {

company.name = \testRequestCompany${Math.floor(Math.random() * 100)}`;`

company.type = "company";

company.class = "internal";

company.location = "167958413122575757";

const insertedCompanyID = company.insert();

if (insertedCompanyID == 0) {

ss.info(company.getErrors());

};

employee_company = insertedCompanyID;

createEmployee();

};

function createEmployee() {

employee.job_title = \manager${Math.floor(Math.random() * 100)}`;`

employee.first_name = \test${Math.floor(Math.random() * 100)}`;`

employee.middle_name = \test${Math.floor(Math.random() * 100)}`;`

employee.last_name = \test${Math.floor(Math.random() * 100)}`;`

employee.email = \employee-test-${Math.floor(Math.random() * 100)}@mail.ru`;`

employee.username = \user${Math.floor(Math.random() * 100)}`;`

employee.mobile_phone = \\${Math.floor(Math.random() * 100)}`;`

employee.timezone_id = "156076775207685877";

employee.work_schedule = "157165292607666710";

employee.company = employee_company;

employee.insert();

};

createCompany();

2 лайка