
formula help - assign team automatically when user is assigned to a lead
Collapse
X
-
Hey @selo
if you want to see the names the teams without refreshing the page, then you can you entity->set instead. Below is how i would use it:
PHP Code:if (entity\isAttributeChanged('assignedUserId') && assignedUserId) {
entity\setAttribute('teamsIds', assignedUser.teamsIds);
entity\setAttribute('teamsNames', assignedUser.teamsNames);
}
Leave a comment:
-
Simple as that, it didn't even occur to me, thank you!
For anyone stumbling upon this discussion, so there is no confusion, if you're looking for EspoCRM to automatically update the team an entity is assigned to when the assigned user is changed, then this is the working code lazovic provided:
Code:ifThen( entity\isAttributeChanged('assignedUserId') && assignedUserId != null, entity\addLinkMultipleId('teams', assignedUser.teamsIds); );
Leave a comment:
-
Hey lazovic , thank you so much for your help.
The code you wrote does it, except that I didn't realize when I ask for the ID, it literally prints the ID in numerical value and not the team name.
So I tried modifying it as such based on your code:
Code:ifThen( entity\isAttributeChanged('assignedUserName') && assignedUser.name != null, entity\addLinkMultipleId('teams', assignedUser.teamsNames) );
Code:ifThen( entity\isAttributeChanged('assignedUserName') && assignedUser.name != null, entity\setAttribute(teamsNames, assignedUser.teamsNames); );
Last edited by selo; 11-07-2023, 06:16 PM.Leave a comment:
-
formula help - assign team automatically when user is assigned to a lead
Hi,
When a lead is manually assigned a user, I'd like that lead to also be automatically assigned to that user's team.
I wrote this script
ifThen(entity\isAttributeChanged(assignedUser.name ), teamsIds=assignedUser.teamsIds)
based on other solutions I saw in this forum but it doesn't work for me.
What am I doing wrong?
ThanksTags: None
Leave a comment: