Custom Field Value disappear in Edit Screen

Abinash Satapathy February 4, 2020

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.

3 answers

1 vote
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 4, 2020

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}
}

 

Abinash Satapathy February 5, 2020

Thanks @Peter-Dave 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

0 votes
Jack Brickey
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 4, 2020

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?

Abinash Satapathy February 4, 2020

Hello I reviewed  my History Tab and nothing shows up there . :(

Br,
Abinash

0 votes
Antoine Berry
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 4, 2020

Hi @Abinash Satapathy 

Have you checked if there is any behaviour for the Project 2 ?

Abinash Satapathy February 4, 2020

Hello Antoine ,

No behavior in the second project .  just two simple projects .

Br,
Abinash

Antoine Berry
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 4, 2020

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 ?

Abinash Satapathy February 4, 2020

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

Antoine Berry
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 4, 2020

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.

Abinash Satapathy February 4, 2020

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

Antoine Berry
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 4, 2020

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

Abinash Satapathy February 5, 2020

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

Suggest an answer

Log in or Sign up to answer