Hello ,
We are facing some strange Issues. We are cloning one Ticket from One project (Lets Say Project1 ) to Project 2 .
Script runner works good . Cloning is happening and fields are also getting cloned from Project 1 to Project 2.
But when we Click on "Edit" in the Issue in Project 2 , the Custom Field Values disappears and it automatically gets set to None even though the Fields are visible in the View Screen.
One thing we have found out that if if the custom field context is common for both the projects then the issue is not happening .
But if we split the context into two for two projects the issue reappears even though the Option values are completely same .
We are not using any behaviors or any scripts in those projects .
Any one facing similar kind of problem.
While I agree from the other answer thread that ideally, mapping any select fields from the original issue context to the cloned issue context should be covered in the built-in postfunction "clones an issue and links".
I think maybe something like this may work (not tested)
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.config.FieldConfig
def keysWithOptions = [
'com.atlassian.jira.plugin.system.customfieldtypes:select',
'com.atlassian.jira.plugin.system.customfieldtypes:multiselect',
'com.atlassian.jira.plugin.system.customfieldtypes:cascadingselect',
'com.atlassian.jira.plugin.system.customfieldtypes:multicheckboxes',
'com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons'
]
ComponentAccessor.customFieldManager.getCustomFieldObjects(issue).each{cf ->
if(cf.customFieldType.key in keysWithOptions ) {
def cfVal = issue.getCustomFieldValue(cf)
def oldConfig = cf.getRelevantConfig(sourceIssue)
def newConfig = cf.getRelevantConfig(issue)
if(cfVal){
if(oldConfig.id != newConfig.id ){
def newVal
if(cfVal instanceof ArrayList ){
//findAll{it} should remove any nulls
newVal = cfVal.collect{ getNewOption(newConfig, it.value )}.findAll{it}
} else {
newVal = getNewOption(newConfig, cfVal.value )
}
if(newVal){
issue.setCustomFieldValue(cf, newVal)
} else {
//no matching option in the other context
// i'm not sure if it would still get cloned, but best force null
issue.setCustomFieldValue(cf, null)
}
}
}
}
}
def getNewOption(FieldConfig newConfig, value){
def optionsManager = ComponentAccessor.optionsManager
def newOptions = optionsManager.getOptions(newConfig)
return newOptions.find{ it.value == value}
}
Thanks @PD Sheehan ,
I will giev a try on the code provided by you.
Today i tried to clone using JSU and JMWE plugin and both this plugin works like charm. Fields with shared context behaves as expected . :)
It seems this is an bug with scriptrunner .
Br,
Abinash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you review the history or all tab to see if it provides a clue. Is there an entry that indicates the field’s value changed?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello I reviewed my History Tab and nothing shows up there . :(
Br,
Abinash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you checked if there is any behaviour for the Project 2 ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Antoine ,
No behavior in the second project . just two simple projects .
Br,
Abinash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am terribly sorry I missed the part in italics and below. I would have suspected a custom field configuration too. Do you dynamically see the value "disappearing" when you edit the issue ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The values are not visible in edit screen at all . I mean no dynamic disappearing is happening .
If i select any option and click on Save then the value appears .
Br,
Abinash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Even though two contexts have the same text values, their references are different. The issue will retain its custom field value after a context change. But when you try to edit the issue, the reference for the current value is not present in the new context, edit issue screen cannot display it and the value disappears.
In short, the reference for the custom field value is not available when splitting the two contexts.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Antoine Berry ,
Thanks for the explanation but ideally it shouldn't behave like this . :(
Do you have any suggestions how to tackle this scenario .
Abinash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I understand that in your case it can cause some confusion/frustration. If these two projects are to share the same values, I would advise to keep only one context. The logic behind is to ensure data integrity. Thanksfully you can rollback if you merge the two contexts again.
Then again I am not a Jira developper, you could suggest a development to the atlassian team. :)
Best,
Antoine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Antoine Berry ,
Thanks for the suggestions .
Today i tried to clone using JSU and JMWE plugin and both this plugin works like charm. Fields with shared context behaves as expected . :)
It seems this is an bug with scriptrunner .
Br,
Abinash
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.