Hi,
I want to write a script runner behaviour script based on the Profield value. Can someone please tell me how to get the field value. Based on the value, i will set another field to Hidden.
thanks in advance!!
I have tried as i do for normal custom field. But It didn't work out. Please find my code below,
import com.atlassian.jira.project.Project
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
//Defining Audience custom field object
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def audienceField = customFieldManager.getCustomFieldObject("customfield_16603");
Project project = getIssueContext().getProjectObject()
String projectCategory = project.getProjectCategory().getName() as String
String projectKey = project.getKey()
def feature_link_field = getFieldById('customfield_15727') // Defining an object for Feature Link issue
if(underlyingIssue.getCustomFieldValue(audienceField).toString() == 'Development') {
feature_link_field.setHidden(false);
}
HI.
import com.atlassian.jira.component.ComponentAccessor;
def audienceField = getFieldById("customfield_16603")
if(audienceField.getValue().toString() == 'Development')
getFieldById("customfield_15727").setHidden(false)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @nallu ,
As I understand from your code, you get audienceField from the issue (not in screen pop-up),
Why do you need projectKey and category? You didn't use these variables. Also, if you face an issue with this script, you can use field.setHelpText() to see variables. Or put log.error() to some lines and check atlassian-jira.log file.
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Tansu Akdeniz , Thanks for the response.
Yes. What you understand is correct. I was just playing with project key and category. Actual use case is, I need to display the 'Feature_link_field' if audience == 'Development'. I want have this behaviour in all the screens (including create screen).
Note: Audience is Profield which is mapped with any screens.
Here is my code,
import com.atlassian.jira.project.Project
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
//Defining Audience custom field object
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def audienceField = customFieldManager.getCustomFieldObject("customfield_16603");
//def audienceValue = underlyingIssue.getCustomFieldValue(audienceField).toString();
def feature_link_field = getFieldById('customfield_15727') // Defining an object for Feature Link issue
feature_link_field.setHelpText("Hi Test!!");
/**
if(audienceValue == 'Development') {
feature_link_field.setHidden(false);
}
**/
As you have suggested, I have tried using the setHelpText. The help text display correctly when the below line is commented.
//def audienceValue = underlyingIssue.getCustomFieldValue(audienceField).toString();
When it is Uncommented, the help text fails to display. so i think, there is something wrong with that line.
Please help..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @nallu ,
Is that Audience field stored in an issue? If not, following method returns null.
Please check;
String audienceValue = underlyingIssue.getCustomFieldValue(audienceField);
feature_link_field.setHelpText("Audience Value: " +audienceValue);
Do you mean Profields for Jira add-on by profields (Audience)? If yes, you need to search for a Java method to get this value. Because it is a Project based customfield.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It is stored in project level only. But the value will also get stored for individual issues in that project as well. I am able to get the data in script field.
And, Yes it is a add-on Profileds.
When I add this line, it not at all displaying the help text.
String audienceValue = underlyingIssue.getCustomFieldValue(audienceField);
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.