Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

AJS.params.loggedInUser returned login id - what is the equivalent for full name

Hi All,

The below gave me the user login id , do any one know what is the equivalient for user full name ? - Please let me know thanks.

AJS.params.loggedInUser

Is there a document on the above?

Thanks

Saran

3 answers

1 accepted

You need to invoke the REST API to get additional user details. This post has some code: http://www.j-tricks.com/1/post/2012/02/some-ajs-tricks.html

Thanks - I will check this out

can i add it directly in the java script or do i have to do any additonal settings?

When I add it as below - it returns undefiend values in the summary field.

<script type="text/javascript">

var reporter = getCurrentUserName() ;

if (document.getElementById("summary").value == "") {

document.getElementById("summary").value = reporter;

}

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;

}

</script>

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;
}

What version of JIRA is it? Yes, you can add it in in javascript. Also, can you alert the username alone?

What exactly is undefined?

@Jobin Kuruvilla _Adaptavist_ This is not an answer, i am having an issue in calling a Java class method to perform a Ajax call from a VM file. I am new to this and trying to get inputs from experts.

My requirement is to call a method save() in the class SaveConfiguration.java. From various queries raised earlier by others i could see some code snippet in the VM file which does the work, using the URL variable , something like this : 

 

function sub(){
 alert('work');
     
  var url = AJS.params.baseURL + "/secure/ViewTermsConditions!SaveToDb.jspa";
     alert(url);
     var type = 'POST';
     var data = AJS.$("#formId").serialize();
     AJS.$.ajax({
            type: type,
            dataType: 'json',
            url: url,
            async: false,
            data: data, 
            success: function(data)
            {  alert('success');
                JIRA.Messages.showSuccessMsg(AJS.I18n.getText("lineItem.success"));
            },
      error: function(data){
    alert('error');
    
      }
          });
          
 alert('end');
  
     return false; 
 }

I want to understand how reframe the above code to call save() method in the class SaveConfiguration.java. Does it require any modification in atlassian-plugin.xml file.

Please share your comments.Thanks in advance.

Hi ,

when im using following code


<script type="text/javascript">
var user=getCurrentUserName()
alert("rrrrrr"+user)
function getCurrentUserName()
{
var user
AJS.$.ajax({
url: "/rest/gadget/1.0/currentUser",
type: 'get',
dataType: 'json',
async: false,
success: function(data) {
user = data.username;
}
});
alert(6666)
return user;
}
</script>

The username is coming as undefined, what am I doing wrong?

you can refer https://jamieechlin.atlassian.net/wiki/display/GRV/Script+Runner

to simplify your work. its groovy script.

you can get full name using

jQuery('#header-details-user-fullname').html();

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you