Email This Issue - Getting substring from displayname

Elston, Jonathan July 15, 2024

 

 

Inside the HTML Template of Emai This Issue, how can a substring within $!issue.assignee.displayName be obtained and then displayed?"  

(Example:  $!issue.assignee.displayName  = "Sample, Joe")

How could I obtain the substring "Joe"?

How could I obtain the substring "Sample"?

How could I display the 2 substrings as "Joe Sample"?

I know there are substring function in jql but I don't know if those things are available in Email This Issue.

2 answers

0 votes
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 17, 2024

Hi Jonathan,

If using an automation rule/smart values, you can do this:

{{issue.assignee.displayName.split(" ").first}}

0 votes
Tessa Tuteleers
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 15, 2024

Hey @Elston, Jonathan , 

Welcome to the community! 

VTL can use a lot of string functions, including the one you need. 
The trick is to always to calculations within a new variable, otherwise it won't work. 

I wrote it out in different steps for you: 

#set ($myString = "$!issue.assignee.displayName") 

#set ($myArray = $myString.split(" "))
#set($length=$myArray.size())
#set($last = $length - 1)

$myArray[$last]

You need to follow these steps: 

  • get your string (in your case assignee)
  • break the string up into an array using a delimiter (I used a space here, but you can use whatever you need
  • calculate which part you need ->  always do this in a variable
    • the first part is 0
    • the last part is whatever the length of the list of parts -1 (what I printed)
  • print the part you need

 

Hope this helps! 

- Tessa

 

 

 

Elston, Jonathan July 16, 2024

Thanks. I'll try it out.  Would the following work if currentUser.displayName = lastName, firstName?

#set ($displayName = “$!currentUser.displayName”)

#set ($myArray = $displayName.split(“,”))

$myArray[1] $myArray[0]
Like # people like this
Tessa Tuteleers
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 17, 2024

Hi @Elston, Jonathan

Looks good, it should work. But test it out just in case and let me know if the result is not what you expect. 

I'm not sure currentUser works in this context, so I would be happy if you let me know, so we can learn from each other! 

If this answer helped you, please accept it so others can find the solution to a similar question faster. 

- Tessa

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events