Issue with entity\isNew() method failing to retrieve ID
Collapse
X
-
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/ -
Id might not have been initialized yet by the time of execution of this formula script. Do you use before save script or after save workflow?Leave a comment:
-
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);
}
Leave a comment:
-
Issue with entity\isNew() method failing to retrieve ID
When I create a user, I want to create a piece of data, but the newly created user.id cannot be obtained.
Tags: None

Leave a comment: