Hi all,
We are running a category of projects with tasks and subtasks. In this category there is a requirement to have all the component/affected/fixversion in subtasks equal to it's parent task.
Users with appropiate permissions can change these fields via the "Edit" operation in Tasks, but in subtasks the screen associated to the Edit op doesn't show any of these 3 fields. Then, a listener is catching all edit events from the project category, to copy those 3 fields to its subtasks. So the only way to update these 3 fields is editing this in the parent task and letting the listener do it's work.
But unfortunatelly the listener has some bug that leads to subtasks showing old version info in the Search screen (causing the filters showing incorrect results), but showing the correct info in the issue screen.
Our guess is that it's somewhat related to the order of storing the tasks/subtasks in the listener (?). Only a locking reindex fix this (background indexing doesn't!).
Is there some jelly/groovy example scripts to copy these 3 fileds from parent to subs without locking the whole instance? Is this doable only with Jelly? We need some interim solution while fixing the listener ...
Thanks in advance.
Community moderators have prevented the ability to post new answers.
Our mistake:
There was a different version deployed in production and stagging environment. The issue was fixed in a old version but never deployed to live ...
Plonk!
instead of using edit operation you can create global WFA action something like "update versions" and add those three fields to that screen then using postfunction you can copy over to subtask
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What about using "Jira Misc Workflow Extensions" Set Field Value from Parent post function ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Boris,
I already installed that plugin, but the problem is that this "copy" is implemented as a postfunction, so I can only "link" this to a transition (Edit is an operation, not transition). Hence our need to implement this as a listener, or as a script while fixing the original listener ...
thx
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Potential sources to the problem (IMO):
-calls to ImportUtils.setIndexIssues, but Ive seen them in all the examples I found.
-IssueManager.updateIssue doesn't update the indexes? Need for the MutableIssue.store()?
-using old listener interface
public class SyncEdicion extends AbstractIssueEventListener implements IssueEventListener { ..... ..... public void workflowEvent(IssueEvent event) { Issue i = event.getIssue(); // event from a "controlled" projet? if (i.getProjectObject().getProjectCategoryObject().getId().equals(this.prjCategory)) { boolean wasIndexing = ImportUtils.isIndexIssues(); ImportUtils.setIndexIssues(true); try { this.handleFields(event); } catch (IndexException e) { e.printStackTrace(); } catch (EntityNotFoundException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } ImportUtils.setIndexIssues(wasIndexing); } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
private void copyAffectedVersion(Issue src, MutableIssue dest) { log.debug("copyAffectedVersion"); Collection<Version> affectedVersions = new ArrayList<Version>(); Version myVersion; Iterator ite = null; GenericValue gv = null; ite = src.getAffectedVersions().iterator(); while (ite.hasNext()) { myVersion = (Version) ite.next(); gv = myVersion.getGenericValue(); affectedVersions.add(myVersion); } dest.setAffectedVersions(affectedVersions); }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
private void handleFields(IssueEvent event) throws IndexException, EntityNotFoundException, Exception { Iterator ite = null; MutableIssue mi, smi; boolean updated; mi = (MutableIssue) event.getIssue(); if (!event.getIssue().isSubTask()) { // propagar T -> ST ite = mi.getSubTaskObjects().iterator(); while (ite.hasNext()) { updated = false; smi = (MutableIssue) ite.next(); // this copy the affected version from task to subtask. There are other to compare and copy fixVersion and components, but removed from the sample code if (!mi.getAffectedVersions().equals(smi.getAffectedVersions())) { log.debug("copiando version afectada"); this.copyAffectedVersion(mi, smi); updated = true; } if (updated) { log.debug("storing"); ComponentAccessor.getIssueManager().updateIssue(event.getUser(), smi, EventDispatchOption.DO_NOT_DISPATCH, false); // smi.store(); ? } } } else { smi = (MutableIssue) event.getIssue(); mi = (MutableIssue) smi.getParentObject(); updated = false; // event raised from a subtask, ensure that parent task have same affected versions or copy from it. if (!mi.getAffectedVersions().equals(smi.getAffectedVersions())) { log.debug("copiando versiones afectadas"); this.copyAffectedVersion(mi, smi); updated = true; } if (updated) { log.debug("storing"); ComponentAccessor.getIssueManager().updateIssue(event.getUser(), smi, EventDispatchOption.DO_NOT_DISPATCH, false); // smi.store(); ? } } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you post your listener code?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.