How to return the full author name for the last comment

Hi

I have been using the script runner to send out some automated emails to external clients when the issue is commented on. However I got a bit stuck with adding the Full name of the author of the last comment.

Using ${componentManager.getCommentManager().getComments(issue).last().author} in the email body I am able to return the code of the author of the last comment e.g. jsoap but I require the full name e.g. Joe Soap.

Is there a way to retrieve the full name?

Thanks

David

5 answers

1 accepted

0 vote

You should be able to just append .displayName to what you have already.

Thanks guys for the replies. No success yet with either options

@Vinjay

It doesn’t seem that the ComponentAccessor class is used in script runner

groovy.lang.MissingPropertyException: No such property: ComponentAccessor for class: groovy.tmp.templates.GStringTemplateScript229

@Jamie

Similar issue it doesn’t recognise displayName when I tried the following

${componentManager.getCommentManager().getComments(issue).last().author.dispalyName}

groovy.lang.MissingPropertyException: No such property: dispalyName for class: java.lang.String)

Any other ideas? Is there a way for me to add the class/property to the underlying script.

No such property: dispalyName

hehe see where you are going with that, even with the Proper spelling I still get the same issue

Stack Trace:

groovy.lang.MissingPropertyException: No such property: displayName for class: java.lang.String
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50)

OK, use:

authorUser.displayName

Excellent. Thank you Jamie this works perfectly

Hi David,

You have to get the user from the author using userutils.

ComponentAccessor.getUserUtil().getUserObject(ComponentManager.getComponentInstanceOfType(CommentManager.class).getComments(issue).last().author).getDisplayName()

This is groovy syntax. May be this helps.

Vijay

Hi David,

You have to get the user from the author using userutils.

ComponentAccessor.getUserUtil().getUserObject(ComponentManager.getComponentInstanceOfType(CommentManager.class).getComments(issue).last().author).getDisplayName()

This is groovy syntax. May be this helps.

Vijay

Hi David,

You have to get the user from the author using userutils.

ComponentAccessor.getUserUtil().getUserObject(ComponentManager.getComponentInstanceOfType(CommentManager.class).getComments(issue).last().author).getDisplayName()

This is groovy syntax. May be this helps.

Vijay

${componentManager.getCommentManager().getComments(issue).last().authorUser.displayName}

this works fine

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

240 views 1 18
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