Hello, im currently working on a new app in tabidoo platform and can’t find a solution to giving a role to a user after sign up… my current code is in workflow automations and no errors are logged in
(async (doo: IDoo) => { // do not change this line
const userEmail = String(doo.model.login.value||'').trim().toLowerCase();
if(!userEmail){
return;
}
const existingEmployee= await doo.table.getCount("Employees",{
filter:`email(eq)${userEmail}`
})
const roleName = (existingEmployee.data.count > 0)? 'employee':'company_admin';
const roleRecords = await doo.table.getData<IDooApiTableRole>("Role",{filter:`name(eq)${roleName}`})
if(!roleRecords ||roleRecords.data.length===0){
return;
}
const foundRecord = roleRecords.data.at(0).id
try{
doo.model.role.setValue(foundRecord)
}catch(e){
console.log(e)
}
}) // do not change this line
Any help would be really appreciated
Thanks