Hi People,
Is it possible to create a new ticket using custom button on the Jira Ticket screen, whenever the custom field gets updated - for the following scenario:
We have field called "Variant" which is Multiple Select drop down. The variant should be selected from a list include all the variants our system supported.
Now we have custom button "Yokoten" on the Jira ticket screen - This button will be always shown to the users on the screen regardless the status of workflow. When yokoten button is clicked the following changes should happen.
May I Know how can we get this requirement using scriptrunner or any other methods.
Thanks in Advance,
Hi @Sahish
Personally I would try to achieve this using automation based on the Variant field being updated. You can test before and after values to pick up the deletion.
You can also achieve it in scriptrunner, the question then being what would trigger the script to run?
How are you creating the Yokoken button?
Hi @Tom Lister
I have created the Yokoten Button by creating a transition "Yokoten" from any status to itself, and I added a property opsbar-
sequence
=0 so that it would stay as a Transition button.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Sahish
Never used the opsbar-
sequence
=0 setting. Good tip!
If Yokoten is a workflow action then you can run the script as a post-function. And groovy in scriptrunner can perform all the actions you describe.
I am wondering about some functional issues. If you intend the creation to be manually triggered by a user the script post function is a viable option. But would you need a condition to prevent the user running this option more than once and duplicating the ticket entries. One option is to create a scripted condition to check the existence of tickets - but there would need to be clear criteria for the search, maybe add the variant field to the linked tickets.
Detecting when a variant is deleted will be difficult as it can be removed independently of a workflow action. So I will keep to my recommendation to use automation for this.
This will take a while to build and test. Are you looking for detailed help on this?
As an example these pieces of code create and check subtasks based on workflow properties - not quite what you need but may be of use to understand the concepts.
(it uses some classes I defined in scriptrunner located here
https://github.com/listertuk/groovy/blob/2ded1edab2bdf4c266ee2fb4720a827ddf4effd8/server-dc/com.domain1.retail/com/domain1/retail/ShoptectSubTaskChecker.groovy
The automation part for variant deletion could look something like this
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Tom Lister , thanks for the reply. wWill go through the docs which you shared. But I am looking for some detailed help on this. I am looking forward.
Thanks in advance,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI @Sahish
I will try and create some examples for you to follow.
A text search on all issue can be slow - how big is your Jira instance (number of issues?)?
Do you want to prevent the yokoten button being clicked twice for the same variant by mistake?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In case this is useful to you. This is how I set up a separate logger for debugging scripting. The conversion pattern is omitted as I usually want the raw output logged with out any date/class info prefixed. On your server installation you will need to find the file <jira-install>/WEB-INF/classes/log4j.properties and add the following snippet.
##################################
# scriptrunner logging
##################################
log4j.appender.scriptlog=com.atlassian.jira.logging.JiraHomeAppender
log4j.appender.scriptlog.File=atlassian-jira-script.log
log4j.appender.scriptlog.MaxFileSize=20480KB
log4j.appender.scriptlog.MaxBackupIndex=5
log4j.appender.scriptlog.layout=com.atlassian.logging.log4j.NewLineIndentingFilteringPatternLayout
log4j.appender.scriptlog.layout.ConversionPattern=
#%d{yyyy-MM-dd HH:mm:ss,SSSZ} %t %X{jira.username} %X{jira.request.id} %X{jira.request.assession.id} %X{jira.request.ipaddr} %X{jira.request.url} %m%n
log4j.logger.com.scripts = INFO, scriptlog
In your script add :
import org.apache.log4j.Logger
Logger logit = Logger.getLogger("com.scripts")
logit.info "blah"
Any logit statements in your script will write output to <jira-home>/log/atlassian-jira-script.log
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Sahish
Try this as a starter to search for a match and create an issue
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.
Hi @Sahish
Number of issues shouldn't be a problem as the logic you want is based on looking through the linked issues.
has been updated to
If the post-function is re-run it will find the original issue plus the ones previously created as they will all have the same title. Adding variant prevents adding new issues exponentially.
What behaviour would you expect?
You could change the search to be same title AND same issuetype AND different variant value
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.
Hi @Sahish
in your list of possible post-functions there should be a custom script scriptrunner function
i’ve assumed you have scriptrunner installed as its mentioned in your original post.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Tom Lister ,
I have tried with the above code, but I am not getting the expected output. The new ticket is created with all the Variants which I have added previously. It is also taking the previously updated Variants.
Thank You,
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.