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:
Any help will be greatly appreciated.
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Lenard, thanks for the reply. I'm pretty sure those values are not being changed anywhere, especially in the 'Edit' screen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Olek Lebiedowicz
Could you move the post-funciton
To the last position i.e. after the "Fire a Generic Event..."
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 ;)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ofcourse this is not a sustainable solution but atleast we would get to know that the issue is related to indexing.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.