Changing default value or the list of values of a selection list custom field based on the user logged in

I have a list of values in custom field of type selection list.

Based on the user logged in, I want to change the default selected value of that field.

Also, based on the user logged in,  I want to change the list of values in that field.

Is it possible?

2 answers

Hi @Meenakshi Nainwal,

This feature is not available out of the box in JIRA. I have an idea on how to solve it but I didn't try it.

You could add the following script to the announcement banner:

<script type="text/javascript">
(function($){ jQuery(document).ready(function($){ 
    $(function(){
   
        $.get(AJS.params.baseURL + "/rest/auth/1/session", function (data) {
            userName = data.name;
   
            // check groups
            $.get(AJS.params.baseURL + "/rest/api/2/user", {username: userName, expand: "groups"}, function (data) {
                var groups = data.groups;
                var groupItems = jQuery.map(groups.items, function (val, j) {
if (val.name == "jira-administrators"){
var select = document.getElementById('customfield_10617');select.options.remove(0);//removes the first option
}
return val.name});
</script>

 

The above script should remove the first option of the custom field if the logged in user is in jira-administrators group. You can tweak it to do more options with the custom field.

Another possibility is to use Kepler Database Custom FIeld. This field takes values from database and arrange them as drop down select list. It is configured with SQL query from one of available data sources.

So you can define mapping of your values to users in DB, make sure this DB is available in JIRA as a data source. Then you can add database custom field with SQL query like the following:

select my_value from values_table where my_user = currentuser

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Wednesday in Jira

Join our webinar: How 1B+ feature flag events helped us build the new Jira

Every time you release software, there's a bit of risk – that there's a bug, that something breaks, or that the feature doesn't resonate with customers. Feature flagging helps make high stakes s...

137 views 0 3
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you