can i use the custom filed values based on the issue type
if the script runner .. help can anyone help me in the script
requirement:
in the custom field(cascade) there were ,1,2,3,4 values(in drop down)
if the select the issuetype = bug .. the custom field need to display only 1,4
if issuetype= Story the custom field need to display 1,3,2
if issuetype = test-case the custom field need to display 3,4
Ciao @kiranmai genkolla
you can try with this code within ScriptRunner behaviour
import com.atlassian.jira.issue.Issue;
Issue issue = getUnderlyingIssue();
String issueType = issue.getIssueTypeObject().getName();
def myField = getFieldByName("YOUR FIELD NAME HERE");
if(issueType.equalsIgnoreCase("YOUR ISSUE TYPE"))){
//SET HERE THE BEHAVIOUR FOR YOUR FIELD
myField.set...
}
Please put this code associated to the first field appearing in the screen (ususally summary).
https://scriptrunner.adaptavist.com/5.6.8.1-jira8/jira/behaviours-api-quickref.html use this link to catch your desired behaviour for your field.
Fabio
Hi Fabio,
tried it in the behaviour
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.*
def selectcf = getFieldByName("Ticket Category")
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()
def customField = customFieldManager.getCustomFieldObject(selectcf.getFieldId())
def config = customField.getRelevantConfig(getIssueContext()) //getting error over here
please check and guide me in this
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ciao @kiranmai genkolla ,
try this code
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.customfields.manager.OptionsManager;
import com.atlassian.jira.issue.fields.config.FieldConfig;
import com.atlassian.jira.issue.customfields.option.Options;
Issue issue = getUnderlyingIssue();
String issueType = issue.getIssueTypeObject().getName();
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
OptionsManager optionsManager = ComponentAccessor.getOptionsManager();
def myField = getFieldByName("Ticket Category");
if(issueType.equalsIgnoreCase("Incidents")){
CustomField customField = customFieldManager.getCustomFieldObjectByName("Ticket Category");
FieldConfig config = customField.getRelevantConfig(issue)
Options options = optionsManager.getOptions(config);
myField.setFieldOptions(options.findAll {it.value in ['Platform Customization']});
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
getting the warnings .. but its working
thanks a lot
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You're welcome!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi fabio
as the field was cascade type . Can i also restrict the child value.
in the above script i restricted the parent values from the "ticket category" field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Fabio Racobaldo _Herzum_ Hello
I do have similar kind of requirement.
Currently i have custom field called- Finance service (which has 10 drop down values) as below FB-1,FB-2,FB-3,FB-4 and so on till FB-10.
and based on finance service selection another custom field called budget handler which has drop down values as BH-1,BH-2,BH3 and so on.
and in this project i have 2 issue types such IRB-1 and IRB-2 and now i want set up something like based on Issue Type IRB-1, only first drop down values get appear in custom field finance service and respectively Budget Handler.
similarly wanted to set condition for issue type IRB-2,
could you pls guide me how to start with this.
Thanks
M
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Manoj
It's always best to create a new question so more people will see it and can tailor answers to your specific case.
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 @kiranmai genkolla - I am not clear what you are tying to do. Do you want to see different values in your pick list custom field based on the Issue Type selected?
If so, you can add a new context to the custom field and based it on the issue type. Then you can add different values for that issue type.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
need to use the same custom field (cascading type) for the different issuetype . created the context field but its not able to view the project name with the other issue type
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you post of a screenshot of your context for that issue type?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
unable to view the project name if i use the new context field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What project are you trying to connect the new context to? Do you already use that project with another Context? Can yo provide a full page view with all of the contexts?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
custom field(cascade) there were ,1,2,3,4 values(in drop down)
if the select the issuetype = bug .. the custom field need to display only 1,4
if issuetype= Story the custom field need to display 1,3,2
if issuetype = test-case the custom field need to display 3,4
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you share a full page screenshot of the Context page for that custom field?
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.
So you need to create 3 new contexts - one for Bug, one for Test-case and one for Story.
Only put in the options you want for each one of those issue types.
To create the new contexts, click on the Add new context link at the top.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If I click on add new context link
Iam unable to get any project name in the drop-down of projects
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.