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.
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.