Hi,
I have defined a scripted field "ID" which sets issuekey value to this field "ID" which works fine.
I am migrating project issues(CSV import) into jira where some of the issues has values of ID present already. But after import these values are overwritten with issuekey value.
I have set a IF condition to define only if (id==null) set issue key value to ID. But after project import the ID values are still overwriting.
I have below clarifications
1) If a field is scripted field, the project import values to that field will be overwritten always?
2) If yes then what is the way to define a condition that after project import my condition executes. The current script is in Scriprunner Scripted Fields.
where do i define script to allow project import values of ID without overwriting by Scripted Field condition?
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
def cf = customFieldManager.getCustomFieldObject('customfield_10308')
def id_value=issue.getCustomFieldValue(cf)
//return id_value
if(id_value==null)
{
def key=issue.getKey()
def slash = key.toString()
def id1=slash.replaceAll("[-]",'')
return id1
}else{
return id_value
}
Scripted fields do not contain any data. They calculate and display it.
So the data you imported is irrelevant - there's nowhere to store it, so it is discarded. Next time the issue is indexed, the display will be recalculated by the script. (It's a bit more complex than "when indexed" in reality, but that is the easiest way to think of it)
To get your import to keep your old data, import the values into a standard custom field. You can leave that off every screen if you want, so it doesn't bother the users.
Then change the scripted field so that the script reads the imported field, or calculates a new value as needed.
Hi Nic,
Instead of creating 2 fields(Normal field and scripted Field) Is it possible to place script in Behaviour or Listener so that after import if value is present it returns as it is and if not it will return issue-key value.
For newly created issue after project import in jira, the field ID will have Issue-key. The problem is with existing data in project import.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No. Think about when the script would run. How would it know what to do at the point at which it runs?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I created a normal custom field for importing data and Scripted field will check for condition to generate new one. This worked.
Thanks for the response!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.