Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Custom field value not reflected in Edit view

Olek Lebiedowicz June 6, 2018 edited

Hi all,

 I'm using ScriptRunner post function on issue transition to clone it. During the cloning I'm setting a few custom fields from script, like so: 

import com.atlassian.jira.component.ComponentAccessor

def scf1 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("ReQuest - Issue Type")
def scfv1 = issue.getCustomFieldValue(scf1)
def dcf1 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Issue Type")
issue.setCustomFieldValue(dcf1, scfv1)

The values get set correctly and are visible in the view issue screen. However, on the Edit issue screen, their values are None. If I then accept the edit (even without changing any values) they are being set to None and disappear from the view screen.

The order of postfunctions for that transition is as follows:

  1. Set issue status to the linked status of the destination workflow step.
  2. Add a comment to an issue if one is entered during a transition.
  3. Update change history for an issue and store the issue in the database.
  4. ScriptRunner workflow function - Clones an issue, and links (condition & additional actions apply).
    Issue will be cloned to project same as parent, with issue type Concept
  5. Clear Field Value (JSU)
    • Field: ReQuest - Issue Type
  6. Re-index an issue to keep indexes in sync with the database.
  7. Fire a Generic Event event that can be processed by the listeners.

Any help will be greatly appreciated.

4 answers

0 votes
Abinash Satapathy February 4, 2020

Hello ,

We are also facing similar kind of Issue. Custom field value disappears in the edit screen but can be seen 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 .


Regards,
Abinash

0 votes
Ramakrishnan Srinivasan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 1, 2019

I changed seeing the community code somewhere, this block seems to work

def Prj1_YMonth_cf_prev = customFieldManager.getCustomFieldObjectByName('Prj1-Last Month')
def Prj1_YMonth_cf_next = customFieldManager.getCustomFieldObjectByName('Prj1-Current Month')
def fieldConfig = Prj1_YMonth_cf_prev.getRelevantConfig(jqlIssue)
def value_prj1_next = jqlIssue.getCustomFieldValue(Prj1_YMonth_cf_next)
def thisParentOption = ComponentAccessor.getOptionsManager().getOptions(fieldConfig)?.find { it.toString() == value_prj1_next[null].toString() }
def thisChildOption = ComponentAccessor.getOptionsManager().findByParentId(thisParentOption.optionId)?.find { it.toString() == value_prj1_next["1"].toString() }
def newValue = [:]
newValue.put(null, thisParentOption)
newValue.put("1", thisChildOption)
Prj1_YMonth_cf_prev.updateValue(null, jqlIssue, new ModifiedValue(jqlIssue.getCustomFieldValue(Prj1_YMonth_cf_prev), newValue),changeHolder)

 

 when I run this value from cascade field Prj1_YMonth_cf_next copied to Prj1_YMonth_cf_prev and I see the change in Edit screen as well View; for View, the browser refresh is required

0 votes
Lenard Lee
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 6, 2018 edited

Hello Aleksander,

 

From my understanding of the problem, the Scriptrunner post function works fine. The problem is that when you "Edit" the issue, the field values appear as "None". 

Can you clarify whether you have any other scripts active on your instance which actively changes the field value in the "Edit" screen?

 

Best regards,

Lenard Lee 

Olek Lebiedowicz June 6, 2018

Hi Lenard, thanks for the reply. I'm pretty sure those values are not being changed anywhere, especially in the 'Edit' screen.

Ramakrishnan Srinivasan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 31, 2019 edited

Hi,

 I have the same problem, I am able to see the changes in View screen but not in Edit screen.

CustomFieldManager customFieldManagerX = ComponentAccessor.getCustomFieldManager()
def cfA = customFieldManagerX.getCustomFieldObjectByName('Prj1-Last Month')
log.info cfA
def cfB = customFieldManagerX.getCustomFieldObjectByName('Prj1-Current Month')
log.info cfB
def value = issue.getCustomFieldValue(cfB)
log.info value
def changeHolderX = new DefaultIssueChangeHolder()
cfA.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(cfB), value),changeHolderX)

After running the code above, the change is visible in View screen but when I go to Edit screen, the same field shows None for both parent and child option; the logs show correct

 

2019-02-01 05:24:50,046 INFO [runner.ScriptRunnerImpl]: Prj1-Last Month

2019-02-01 05:24:50,046 INFO [runner.ScriptRunnerImpl]: Prj1-Current Month

2019-02-01 05:24:50,047 INFO [runner.ScriptRunnerImpl]: {null=Feb-19, 1=50%}

I am using JIRA 7.12.3 and Script Runner 5.4.43

Can someone please help us out?

Thank you

with warm regards

ramki 

0 votes
Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 6, 2018

Hello @Olek Lebiedowicz

Could you move the post-funciton

  1. ScriptRunner workflow function - Clones an issue, and links (condition & additional actions apply).
    Issue will be cloned to project same as parent, with issue type Concept

To the last position i.e. after the "Fire a Generic Event..."

Olek Lebiedowicz June 6, 2018

Thanks for the suggestion, @Tarun Sapra. How do you think this could help?

Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 6, 2018 edited

Hello @Olek Lebiedowicz

Could you give it a try, post-functions which are using issue objects generally should be at the end of the list.

Olek Lebiedowicz June 6, 2018

I just tried it, sadly it didn't work.

Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 6, 2018 edited

That's strange, once the clone issue is created and the custom field value is visible on the view screen of the issue, could you please "re-index" the project. The option to reindex project is present in the project admin panel section. Once the reindexing is done then could you check again if the custom field value is present on both view screen and edit screen of the issue.

Olek Lebiedowicz June 6, 2018

I can try this later and let you know. However, even if it works, it's not really a valid solution - we can't re-index the project after every transition of this type ;)

Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 6, 2018

Ofcourse this is not a sustainable solution but atleast we would get to know that the issue is related to indexing.

adiels
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 30, 2021

Hi @Tarun Sapra

 

We're having the same issue (Custome field value is different in Edit and View screens).

Full Reindexing didn't solve the issue.

Do you have any suggestions on what further steps can be taken in order to solve the issue?

Thanks.

Suggest an answer

Log in or Sign up to answer