Originally asked by Megan Zhou on 22 October 2021 (original question)
A project sync issue to B project, need to create or update issue link in B project issue, in Outgoing or Incoming template the script how to implement it?
Comments:
Ariel Aguilar commented on 22 October 2021
Have you looked at:
https://docs.idalko.com/exalate/x/d40rAQ
Let me know if it helps.
Kind regards,
Ariel
Megan Zhou commented on 25 October 2021
We don’t seem to have permission to view this document
Serhiy Onyshchenko commented on 28 October 2021
Hello, Megan Zhou
Sorry for the docs link, that article seems to be archived. Also, by the looks of it’s content it’s a bit unreliable as well.
If if you have local sync (both projects are on the same Jira), you could try adding the following to your incoming sync script:
if (firstSync) {
issue.issueLinks += new com.exalate.basic.domain.hubobject.v1.BasicHubIssueLink(
replica.id as Long,
"is related to ",
"Relates",
com.exalate.basic.domain.hubobject.v1.BasicHubIssueLink.IssueLinkType.ISSUE,
null
)
}
BTW this snippet also relies on Outgoing sync script doing this:
replica.id = issue.id
Please, let me know how it goes,
Serhiy.
Megan Zhou commented on 29 October 2021
It seems that this method does not work
Serhiy Onyshchenko commented on 29 October 2021
Let’s try this instead then:
if (firstSync) {
issue.issueLinks += new com.exalate.basic.domain.hubobject.v1.BasicHubIssueLink(
replica.id as Long,
"is related to ",
"Relates",
com.exalate.basic.domain.hubobject.v1.BasicHubIssueLink.IssueLinkType.ISSUE,
null,
true
)
}
Regards, Serhiy.
Megan Zhou commented on 10 December 2021
Can we add issue link in this way? We want to customize the parent issue, but we were unsuccessful. Do you have any better suggestions?
Megan Zhou commented on 20 December 2021
Hello ,@Serhiy Onyshchenko,
Can you see it for me?
Thanks
Megan
Serhiy Onyshchenko commented on 20 December 2021
Hello, Megan Zhou
With the outgoing sync script that you have, all the children issues would be linked to the same parent - is it intended?
Could you elaborate on
We want to customize the parent issue
In what way would you like to customize it?
but we were unsuccessful
What happened was any link created?
Regards, Serhiy.
Megan Zhou commented on 20 December 2021
Hello ,@Serhiy Onyshchenko,
My test script is associated with a parent issue, and the parent issue will be distinguished based on the value of a fixed file in the future. But the same parent issue used now has not been added successfully.
Thanks
Megan
Serhiy Onyshchenko commented on 20 December 2021
Aha, so no new link is generated overall, right?
Is this supposed to be the standard sub-task link, and not the issue link from /secure/admin/ViewLinkTypes!default.jspa :
Megan Zhou commented on 20 December 2021
I think it is a issue link from /secure/admin/ViewLinkTypes!default.jspa
Serhiy Onyshchenko commented on 20 December 2021
BTW, I can see that the incoming script is adding that link only once upon the first sync.
What are the steps you take to test it?
Megan Zhou commented on 20 December 2021
I created an issue in the tested project and used this script to synchronize to another project. I found that the issue has been synchronized and the issue link was not added successfully.
Serhiy Onyshchenko commented on 21 December 2021
Hey, Megan Zhou , indeed, your config looks just right for this.
In such case, I’d suggest to try using the Jira API to create the link.
First - make sure the issue is created by using: Epic.groovy
Epic.CreateIssue.create( replica, issue, syncRequest, nodeHelper, issueBeforeScript, remoteReplica, traces, blobMetadataList) {
}
// now the issue is created and issue.id points to the newly created issue
Second - use the ComponentAccessor.issueLinkManager to create the issue link between the source and the target issues (also found this as an example: https://docs.idalko.com/exalate/x/SQSOAQ).
Please let me know if you need any further guidance on that
Regards, Serhiy.
Megan Zhou commented on 23 December 2021
I will try it according to the method you provided, thank you very much for your help。
Thanks
Megan