user expression not working with a variable
Hi,
I create a variable to use in the user expression of my workflow
def recipient
if (ListDataManager.isEmpty())
{
recipient = ("role(Data Gov Office;${communityName};${domainValueName})")
}
else
{
recipient = ("role(Data Manager;${communityName};${domainValueName})")
}
It’s work well when I pu ${recipient} in the ‘To’ of a mail task
But it is not working when I do the same in the 'User expression" of the users task,
I have this error message
recipient :role(Data Gov Office;ZZ-Test;TEST-Glossary)
User expression: [email protected] did not resolve to a user
The user expressions were unresolvable:
I don’t underwent why because when I put
role(Data Manager;${communityName};${domainValueName})
Instead of ${recipient} it works
Any ideas ?
Daphné OZBEK
Posted 4 years ago · Edited 1 year ago·Last reply 4 years ago
7 comments
arthurburkhardt
·4 years ago · EditedCould you send a screenshot of your configuration of the user task? (just the user expression field)
Daphné OZBEK
OP4 years ago · EditedI finally find a solution
I put it here in case of something have the same problem
def recipient
if (ListDataManager.isEmpty())
{
recipient = (“Data Gov Office”)
}
else
{
recipient = (“Data Manager”)
}
I don’t know why it’s works better than that
if (ListDataManager.isEmpty())
{
recipient = (“role(Data Gov Office;${communityName};${domainValueName})”)
}
else
{
recipient = (“role(Data Manager;${communityName};${domainValueName})”)
}
arthurburkhardt
·4 years ago · Editedindeed…
In the meantime, you would probably enjoy this syntactic tip for groovy: ternary expression.
So you can write:
and it seems
ListDataManageris an instance, not a class, so to follow standard naming convention, you had better name itlistDataManageror maybe evendataManagers.Daphné OZBEK
OP4 years ago · EditedHi thansk for the tip !
You’re right, I should be more conscientious on the syntax standard !
arthurburkhardt
·4 years ago · EditedAhaha, I hope I did not come across as patronizing, I’m merely happy sharing good practices.
I’m thinking at some point releasing some coding best practices for our teams, I’ll try to share that here as well.
arthurburkhardt
·4 years ago · EditedNot sure what you did, but it seems that you set the the “To” field to your email address:
[email protected], which is not a valid user expression.You should not put your email in the “To” field, but a user expression, such as
user(${userName})orrole(Data Manager;${communityName};${domainValueName})Daphné OZBEK
OP4 years ago · EditedHi,
Yesit it what I did as
recipient = (“role(Data Gov Office;${communityName};${domainValueName})”)
And it is working in the TO of the email (I put ${recipient} )but not working in the user expression in the user task
right after and I don’t understand why