Hi,
I'm trying to add a "copy value from field to field" post function to my workflow - And I need it to be executed when condition is "true".
Please let me explain the scenario:
***************************************************************************
I need to get my issue assigned to the Component Lead automatically when it is being created (This is very easy to fulfill). But, I also have to assign to other people as needed (on the create-issue screen). That's not possible to put select user in "Assignee" system field (because it will still be assigned to the Component Lead). So, I added a new USER PICKER field, then add a post function to copy the value from the user picker field to the "Assignee" field.
I've tried with a few scripts, but was not successful.
Here are my 2 groovy scripts I put in [Conditional execution]:
***************************************************************************
// 1 //
if(!issue.get("customfield_11200")?.getName()){
return true
} else {
return false
}
//or *****************************
// 2 //
if(issue.get("customfield_11200").getName() != ""){
return true
} else {
return false
}
--------------------------------------------------------------------------
The issue is this script seems always return "true" value - means if I select a user then it works - if I keep it empty, then it throw errors - so the empty value here is not correct! I've tried "", null, empty - All are not accepted-.
Could you please advise what is the empty value for a user picker field??
OR, when I used the first script, it always return "true" - Assign to a user I put in the USER PICKER field or "Unassigned" when keep the filed empty. How can I resolve this issue?
Thank you in advance!!
Thanks & Regards,
Olivier Chen
As Nic said, you can just use a simplified version, but your code is wrong, there is no issue.get
. Unless you're thinking of another plugin. The following will work :
import com.atlassian.jira.component.ComponentAccessor def customFieldManager = ComponentAccessor.getCustomFieldManager() def customField = customFieldManager.getCustomFieldObject("customfield_11200") if (issue.getCustomFieldValue(customField)) { ... }
But if this is in a condition block it's still simpler:
cfValues["Name of CF"]
That should be all you need to test if there is a value set.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When a custom field is empty, there's actually nothing in the database for it. So all your "get" functions sort of fail.
But it does make your code more simple. Try:
Which means "if there is a value, then do something"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.