Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×Hi Team,
Could you please help on this script. I am very new to grrovy script
How Can we set the capitalization field automatically based on the value of BugType field, meaning if the BugType is Production set Capitalization to No and if the BugType is Pre-Production set Capitalization to Yes.
My thought on doing this would be to create a script runner Script Custom Field. This would make the field read-only but can be searchable, and the value would be dependent on a script. That way you can have the script check the value of the BugType type field and present the "Yes" or "No" values automatically and change whenever the BugType field changes.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sure. Here's a sample. The return sets the value of the scripted field. It looks up the custom field based on name. There is another function which may be safer which looks up the function based on Id, called getCustomFieldObject(). I used the function which looks up by name to make the code easier to follow but could return a collection of customfield objects based on the API.
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def myTestField = customFieldManager.getCustomFieldObjectsByName('BugType');
//def myTestField = customFieldManager.getCustomFieldObject(10024);
def testvalue = issue.getCustomFieldValue(myTestField);
if (testvalue.toLowerCase() == 'production') return "No";
else return "Yes";
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 Now
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.