Hi,
We are trying to achieve the following in our Jira Ent Cloud and allowed to use any plugins or custom code. Any suggestion will be highly appreciable.
Thanks
You would need to script this.
My suggestion is that you add the script to your post function of your create transition and the script does the following:
I will recommend scriptrunner for this job(a paid add-on but they have a very active community).
You can look up get value of field samples for the add-on and you can look up how to assign an issue to a user.
I hope this helps.
Regards.
Thanks for sharing the idea and possible approach. As we are on the On-demand cloud enterprise edition, there are some limitation on installing plugins just for a requirement to a project in Jira as it impact the entire enterprise edition used by 500+ projects.
Is there any other possible options without it?
Thanks again for your input.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It would be near impossible without a custom script and add-on. JIRA has no built in way to set the value of a field based on another field.
With the only other solution coming to mind being splitting the projects based on Geo location/team that would work on it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the details again. Got the confirmation that we have ScriptRunner installed in our Ent edition of Jira. Could you help on how to get started with ScriptRunners. It seems there were very less tutorials online and to the detailed.
http://scriptrunner-docs.connect.adaptavist.com/jiracloud/quickstart.html
Could you share any video / tutorial links which talks about creating custom fields, dynamic fields etc ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Akbar,
Sorry for the late reply.
You can learn about Scriptrunner for Cloud here. Also as Scriptrunner is based on the REST API for Cloud, you will want to familiarize yourself with this.
Your original description points to you wanting to update a field based on another field.
In such a case, you would need to:
Hope the above helps with getting you started.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
/**
* Author: Ismael Olusola JIMOH
* Product: Atlassian JIRA Cloud
* Description: Set the value of the Territory Manager Field based on What is selected as the Territory field
*/
package com.adaptavist.sr.cloud.samples.events
def projectKey = "ABCD"
if (issue == null || issue.fields.project.key != projectKey) {
logger.info("Wrong Project ${issue.fields.project.key}")
return
}
def issueKey = issue.key
def territory = 'customfield_10030'
def territoryManager = 'customfield_10031'
def territoryResult
def managerResult
def result = get("/rest/api/2/issue/${issueKey}?fields=${territory}")
.header('Content-Type', 'application/json')
.asObject(Map)
if (result.status == 200) {
territoryResult = result.body.fields[territory].value.toString()
//return territoryResult
if(territoryResult=="[UK]"){
//Replace the value in the name put parameter with the name of the current territory manager
def setManager = put("/rest/api/2/issue/${issueKey}?fields=${territoryManager}")
.header('Content-Type', 'application/json')
.body([
fields:[
customfield_10031:[
name:'''<username goes here>'''
]
]
])
.asObject(Map)
return setManager
}else if(territoryResult=="[US]"){
//Replace the value in the name put parameter with the name of the current territory manager
def setManager = put("/rest/api/2/issue/${issueKey}?fields=${territoryManager}")
.header('Content-Type', 'application/json')
.body([
fields:[
customfield_10031:[
name:'''<username goes here>'''
]
]
])
.asObject(Map)
}else if(territoryResult=="[Germany]"){
//Replace the value in the name put parameter with the name of the current territory manager
def setManager = put("/rest/api/2/issue/${issueKey}?fields=${territoryManager}")
.header('Content-Type', 'application/json')
.body([
fields:[
customfield_10031:[
name:'''<username goes here>'''
]
]
])
.asObject(Map)
}else{
return "Global or more than one territory was selected, select only one Territory."
}
} else {
return "Error retrieving issue ${result}"
}
This is a sample I wrote a while back where I am checking the value of a field Called Territory and Setting the Territory Manager.
So the concept of what you will be achieving is similar to the above.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks a ton for this script and i will try to see how i can fit this in my requirement.
I will definitely will come back for other questions and thank for taking time to address.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ismael, One other quick question. I was getting an error when trying the following code. The error is on using the setHidden and setRequired. I was trying to show / hide a text field based on the selection of value select field.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.resolution.Resolution
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()
def complianceReviewNotRequiredField = customFieldManager.getCustomFieldObjectByName("Compliance Review not required")
def complianceReviewField = customFieldManager.getCustomFieldObjectByName("Compliance Requirement")
def selectedOption = complianceReviewField.getValue(issue).toString()
def isOtherSelected = selectedOption == "Approval Not Needed"
if(selectedOption == "Approval Not Needed"){
complianceReviewNotRequiredField.setHidden(false)
complianceReviewNotRequiredField.setRequired(true)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Akbar,
I am unfamiliar with these methods. Also our code looks like it was written for Server rather than Cloud because with Cloud most calls are based on the Cloud Rest API.
Secondly, you are getting a custom field object rather than the customfield itself.
Replace:
def complianceReviewNotRequiredField = customFieldManager.getCustomFieldObjectByName("Compliance Review not required")
def complianceReviewField = customFieldManager.getCustomFieldObjectByName("Compliance Requirement")
With:
def complianceReviewNotRequiredField = getFieldByName("Compliance Review not required")
def complianceReviewField = getFieldByName("Compliance Requirement")
This should fix the issue you are having with the setHidden but I still do not know are you working with Cloud as you stated earlier or you are running JIRA on your own server?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is best explained here: https://community.atlassian.com/t5/Jira-questions/error-on-setHidden/qaq-p/771745 but note my question on which JIRA you are using.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ismael, Sorry for the confusion and just got a confirmation from our systems that we are running jira Server instance not the Cloud. I know it's my mistake for not informing.
We are on the server version 7.6.4. I know this will be a repeated work but could you pls clarify me on the above code you have provided for handling approvals will work on server version?
Thanks in Adavance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As you are using Server, then the original script I provided you will not work.
The section I corrected for you in the code you shared should. Do test it and if you have any questions, let me know and specify what the error is.
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Finally i made it working. Thanks for your suggestions.
def extCommSelectCf = getFieldById("customfield_18903") //get the field ID for Linked to externally committed release date (e.g. marketing)?
def extCommmDateCf = getFieldById("customfield_18902") //get the ID for Externally Committed Launch Date
extCommmDateCf.setHidden(true);
if (extCommSelectCf.getValue() == "Yes"){
extCommmDateCf.setHidden(false);
extCommmDateCf.setRequired(true);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ismael, would it be possible to share the modified jira server version of your territory manager code? or let me know which areas needs change.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Unfortunately, I do not have the script in server version.
also though the logic is the same all the get and put sections must be replaced which means a rewrite of almost the whole script
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.