I have a Field for two issue types (A , B) in a project. It is a Select List (single choice) type custom Field.
If Value of Field matches with other issue of B issue type that issue has to link to the current created issues automatically.
Please help me with Scriptrunner script code for listener.
You could use automation for JIRA to listen the Field change then run a scriptrunner action that will get all issues that have the value and not linked yet.
You could use a script like this one to achieve what you are looking for
String issueKey = issue.key
String fieldValue = ruleContext.renderSmartValues('{{issue.customfield_XXX}}') // XXX is your customfield id
Issues.search('field = ${fieldValue} and type = B and project = XXX and issueFunction not in linkedIssuesOf("key = ${issueKey}")').each { issue ->
Issues.getByKey(issueKey).link('linkName', issue)
}
Regards
Thank you for your response.
Could you please explain how to set up automation in Jira server 8.13.2 with Scriptrunner onboard.
The workflow: ticket created in issue type A has customfield1 value TEST,
One of existing ticket of issue type B has the same value TEST in customfield1
How to find and link first ticket with second on the tciket creation stage?
How to update a couple of fields in new created ticket from linked ticked.
Please help me with Scriptrunner script code.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
I usually use Autoamtion to reduce as much as possible the code to write but everything could be done by Scriptrunner.
You could create an Automation for JIRA that is an app included in JIRA or Free if you are using a Data Center version.
Create an automation with Field value changed as trigger, then select the field customfield1.
You can then add condition in the rule to make sure the issue type is A etc..
Then as action you can add Scriptrunner, it should be available if you have it installed.
In the script section that will be displayed, you can adapt the code I pasted on my previous message.
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Validate your expertise in managing Jira Service Projects for Cloud. Master configuration, optimize workflows, and manage users seamlessly. Earn global 🗺️ recognition and advance your career as a trusted Jira Service management expert.
Get Certified! ✍️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.