You will need to look at the SambaPOS JScript API helpers for api.Entity()
…
… like these:
api.EntityType(name).Entities().State(name).Update(value);
api.EntityType(name).Fields(name).Exists();
api.EntityType(name).Fields(name).Create(fieldtype,[format],[valuesource],[hidden]);
api.Entity(name).State(name).Update(state);
api.Entity(name).State(name).Get();
api.Entity(name).Data(name).Update(value);
api.Entity(name).Data(name).Get();
api.Entity(name).Exists();
api.Entity(name).Create(entityTypeName);
api.Entity(name).CreateAccount([accountName]);