Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Custom field value not reflected in Edit view 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
Tarun Sapra Community Leader Jun 06, 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..."

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

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.

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

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.

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 Jun 06, 2018

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

0 votes

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 

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

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 

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

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

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you