Using Scriptrunner, I defined a postfunction for a transition. In that transition a new issue is created and one of the linked issues of the source issue is set in the issue picker of the new issue.
Works fine.
But:
The above mentioned source issue itself is created by a transition of a third issue. And all issue links are set programmatically on creation.
Which still works fine.
However, in certain circumstances the mentioned source Issue should travel through the above mentioned transition directly after creation (using a FastTrack-Transition-Postfunction in the Create-Transition). In that situation, accessing the linked issues of the source issue fails and returns an empty list of issues.
So it looks to me like the setting of the linked issues during the creation of the source issue and accessing the linked issues happens in the same internal transaction, therefore the linked issues are not yet available.
So how can I tell Jira to first completely create the source issues (including its links to other issues), before starting on the transition of that source issue?
Or is there any other possibility for the root cause of this behaviour, that I overlooked?
You could try including the Listener for this requirement, i.e., a Custom Listener with the IssueCreated event.
So, once the Post-Function triggers the Fast-Track and the Issue is created, the Listener can be used to update the Issue and set the value for the Issue Picker.
It would be good to share your code to get a better understanding.
Thank you and Kind regards,
Ram
Dear @Ram Kumar Aravindakshan _Adaptavist_ ,
yes, defining a Listener would be a possible workaround. But I would prefer to understand and correct ther current behaviour.
This is my implementation (the relevant parts, the complete code would fill several pages and contain dozens of calls to helper-methods):
a) Creating the second issue and setting its values in a postfunction of the first issue
MutableIssue newIssue = ComponentAccessor.getIssueFactory().getIssue()
...
//Setting all necessary fields
...
newIssue = ComponentAccessor.getIssueManager().createIssueObject(user, newIssueParams) as MutableIssue
ComponentAccessor.getIssueLinkManager().createIssueLink(newIssue.getId(), toBeLinkedIssue.getId(), Globals.IssueLinkTypes.RELATES, 1, user)
b) The third issue is created in a postfunction on the "Start progress"-Transition of the second issue
//RetrievedLinkedIssues is null in case that the code from a) and b) is connected using c)
//If a) and b) are triggered separately, everything works fine
def retrievedLinkedIssue = ComponentAccessor.getIssueLinkManager().getOutwardLinks(secondIssue.get())
.stream().filter({it.getLinkTypeId() == Globals.IssueLinkTypes.RELATES})
.map({it.getDestinationObject()}).findFirst()
MutableIssue newIssue = issueFactory.getIssue()
...
//Setting all necessary fields
...
issueManager.createIssueObject(toCreateUser, newIssue)
issueLinkManager.createIssueLink(newIssue.getId(), retreievedLinkedIssue.getId(), Globals.IssueLinkTypes.RELATES, 0, toCreateUser)
c) FastTrack-Condition in the create-Transition of the second issue, connecting the code of a) and b) in one transaction
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I need to check with you; in your last code, you have shown:-
MutableIssue newIssue = ComponentAccessor.getIssueFactory().getIssue()
Why exactly are you using the ComponentAccessor to invoke the issue when you can directly invoke the issue variable in the Post-Function?
For example:-
def issue = issue as MutableIsuse
In your description, you have mentioned:-
However, in certain circumstances the mentioned source Issue should travel through the above mentioned transition directly after creation (using a FastTrack-Transition-Postfunction in the Create-Transition)
Triggering the approach is not 100% guaranteed to be successful when using the Post-Function for the Create transition, which is why I suggested including the Listener to ensure that it will trigger only after the issue has been created.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear @Ram Kumar Aravindakshan _Adaptavist_ ,
I use ComponentAccessor with the IssueFactory to create a new Issue, which I am doing twice in the mentioned process. Each time, I am using some values of the active issue (binded to the variable issue) to fill the values of the new Issue.
So in the part
//Setting all necessary fields
there are statements like
newIssue.setSummary(issue.getSummary)
newIssue.setPriority(issue.getPriority)
I do not understand your statement with the 100% - why shouldn't the postfunction in the create transition work?
Best Regards,
Thilo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register NowOnline 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.