When I create a user, I want to create a piece of data, but the newly created user.id cannot be obtained.
Announcement
Collapse
No announcement yet.
Issue with entity\isNew() method failing to retrieve ID
Collapse
X
-
Make sure that the name of the entity is correct (EmployeeInfo) -> you can check the name under administration > Entity Manager > Employee, also you should use AssignedUserId so it should be as below:
PHP Code:if(entity\isNew()) {
record\create('EmployeeInfo', 'assignedUserId', id, 'joiningDate', datetime\today(), 'baseSalary', 150000);
}
Rabii
Web Dev
-
You are right, id will not be available because all espocrm formula is a before save script which means it is applied before the record is created and saved in db. I think in this case you might want to reach to a afterSave hook which will be perfect for this scenario https://docs.espocrm.com/development/hooks/Rabii
Web Dev
Comment
Comment