Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Hide Custom Field Dropdown Values for Specific Users in Group

Matt Shigekawa
July 20, 2020

We have a use case where we need to hide certain values in a custom field's dropdown for all users except for users in the group critical-issues-management.

 

Custom Field: Critical Issue

Critical Issue Values: None, Minor, Critical 

Scenario 1: critical-issues-management group user sees values: None, Minor, Critical

Scenario 2: Non critical-issues-management group user sees values: None, Minor 

 

Using ScriptRunner Behaviors, we are able to hide the entire custom field (Critical Issues) using the Hide selector, but we are looking for a way to just hide dropdown values based on the above criteria. 

2 answers

Suggest an answer

Log in or Sign up to answer
0 votes
Nir Haimov
Community Champion
February 12, 2019

Hi @Sir Charles Amante

Why are you using HTTPBuilder?

Here is a complete code that will work for you, just copy paste:

import com.atlassian.jira.component.ComponentAccessor;
import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.*;
    
def baseUrl = ComponentAccessor.getApplicationProperties().getString("jira.baseurl");  

//rest api request
HttpClient client = new HttpClient();
GetMethod method = new GetMethod(baseUrl + "/rest/api/latest/issue/WO-440?expand=renderedFields&fields=description");
Credentials credentials = new UsernamePasswordCredentials("jira","jira");
client.getParams().setAuthenticationPreemptive(true);
client.getState().setCredentials(AuthScope.ANY, credentials);
client.executeMethod(method);
def response = method.getResponseBodyAsString()
method.releaseConnection();

return response
Sir Charles Amante
February 12, 2019

Thanks Nir! This returns an error about an empty host or something, but I'm not gonna get basic auth working the way I want anyway when traffic's coming in through a load balancer that's enforcing MFA. 

0 votes
Anton Chemlev - Toolstrek -
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
February 11, 2019

Hi,

Try to found why your request fails. For example:

import groovyx.net.http.HTTPBuilder

def jira = new HTTPBuilder("http://yourjira.com")
jira.auth.basic 'user', 'pass'


jira.handler.failure = { resp ->
    " ${resp.statusLine}"
}

def response = jira.get(path: '/rest/api/2/issue/KEY-123')

This way i get "HTTP/1.1 401".

 

 Your code works for me.

Hector
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
February 12, 2019

Hi,

Your code works fine on my side, but the only thing you are not controlling are the possible exception thrown, so I would suggest defining handlers for HTTP errors as mention by @Anton Chemlev - Toolstrek -

Please refer to https://github.com/jgritman/httpbuilder/wiki/Response-Handlers for further details.

Regards, 

Sir Charles Amante
February 12, 2019

Thank you both! It's our KEMP load balancer causing a 403. Crud. Looking into oauth. 

TAGS
AUG Leaders

Atlassian Community Events