Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Change default value of custom field based on current user

Sir Be July 14, 2014

I have a Custom Field - User Picker (called Manager).

The default value of Manager, when creating an issue, should change depending on the current user.

An example for clarification:

User - Manager

A - 1

B - 1

C - 2

When user A or B, create an issue the default value of the manager field, should be 1.

When user C, does it, it should be 2.

The mapping user-manager can be written in a config file.

Working in JIRA 4.2

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Sir Be July 15, 2014

https://answers.atlassian.com/questions/200222/default-values-in-custom-fields-per-user?utm_source=SAC&utm_medium=dashboard<br< a="">>

&lt;script type="text/javascript"&gt;  
jQuery(document).ready(function($) {
	JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {
			setDefaultValue();    
		}
	);
	setDefaultValue();
	alert("ok");

	function setDefaultValue(){
		var user=getCurrentUserName(); 
		alert("ok hier");
		if( user == 'libra1'){
			//  set default value text field, if the field is select list then add option id instead of text
			$("#customfield_10054").val('hc');
			alert("hc");
		}
		else {
			AJS.$("#customfield_10054").val('admin');
			alert("admin");
		}
	}

	function getCurrentUserName(){
		 var user;
		 AJS.$.ajax(
			{
				url: "/rest/gadget/1.0/currentUser",
				type: 'get',
				dataType: 'json',
				async: false,
				success: function(data) {
					user = data.username;
				}
			}
		);
		return user;
	}
   
 } 
&lt;/script&gt;

doesn't work either

0 votes
Sir Be July 15, 2014
0 votes
Sir Be July 14, 2014

Scripted fields from script runner isn't possible.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events