Lower User Roles not allowed to create higher Role

saw that pic haha…

OK so I’m probably going way off hand here, but:

function userEntity(entityName,entityType) {
  var usr = (typeof entityName === 'undefined' || entityName=='' ? Data.Get("Username") : entityName);
  api.Entity(entityName).Type('Staff');
  return 'Updated';
}

Object doesn’t support this property or method is the error it throws…

I did make a new action in the rule and told it setting of entityName is same as Username

Ok so the api does not need to do any validation in your code. Let me give an example.

… one second.

how blimmin dare it!

here is a check for Employee Type if it does exist it then executes 4 api calls. So you would do the same thing but for Entity exists instead of Entity Type.

var exists = api.EntityType('Employees').Exists();
if(!exists)
{
   api.EntityType('Employees').Create('Employee','TCStatus=PunchOut;TCReport=Unloaded');
   api.EntityType('Employees').Fields('Password').Create('string');
   api.EntityType('Employees').Fields('Pay Rate').Create('number');
   api.EntityType('Employees').Fields('Operator Number').Create('number');
}
result = true;

That might look like:

if (api.Entity('+employee+').Exists())
1 Like

Ok, I understand that… but where is it calling the ‘Employee’ from? or is it going to go at the end of my script?

I only need it to create the Name and Type

api.EntityType(‘Employees’).Create(‘Employee’,‘TCStatus=PunchOut;TCReport=Unloaded’);

that created an entity and also set its default status.

wait I think I get it…

api.Entity(’[:Employee Name]’).Create(‘Employees’);
api.Entity(’[:Employee Name]’).Data(‘Password’).Update(’[:Entry PIN]’);
api.Entity(’[:Employee Name]’).Data(‘Pay Rate’).Update(’[:Pay Rate]’);
api.Entity(’[:Employee Name]’).Data(‘Operator Number’).Update(’[:Operator Number]’);
dlg.AskQuestion(‘Employee named [:Employee Name] added.’,‘OK’);

You will have to modify it… I am showing you some code I used for my time clock Configuration Task. For example ‘Employees’ is a variable I defined in the task… you will have to define it in your jscript.

1 Like

By golly I think were there.

I managed to add an employee entity called [:Username] though lol ill work that out

1 Like

Haha that only works from config tasks. to feed a variable like that you need to use automation.

1 Like

so needs to go in an automation?

No you got it working but you need to feed the actual Entity name from somewhere. [:EntityName] does nothing inside that script… i used that because it was a configuration task.

For your use it might look like (’+entity+’)

ok, well I read what you put about configuration and created a task and added the api

Is that correct?

Oh so your trying to use config task?

So if you want it to work like that then you need to define [:EntityName] here is how.

no idea lol that’s what I thought u said to do above?

what I tried gave me an error

Value cannot be null

I just was showing example jscript syntax… you could just use it in a script and use automation to feed values.

1 Like

Show what you have tried?

I confused you because I am using specific syntax for config task. Sorry I dont have time to keep going but JTRTech should be able to see what I was trying to show.

1 Like

Well, I thought it could already get the data of [:Username] from the script already created for creating the user?

So that’s why I put the script there with that [:Username] in

So, I guess that’s not correct?