How to - edit macros.vm?

Hi all,

we have a JIRA running behind 2 URLs: an internal and external. According to the project many project leads need to have the internal URL in the email templates while the others are satisfied with the default external URL hyperlinks.

We could resolve this request by pasting an if-else statement in each velocity templates:

#if( $issue.getProject().key == "PROJECTKEY")
[ https://yyyyy.yyyy.yyy/browse/${issue.getKey()}?page=${tabpanel-all} ]
#else
[ ${baseurl}/browse/${issue.getKey()}?page=${tabpanel-all} ]
#end

In the meantime we discovered the macros.vm file and with the help of that we could solve this problem much easier:according to our idea the if-else statement takes place in the macros.vm so we'd not need to put the prpoer projectID in each template but only once.

At this point we have 1 problem: we do not understand the macros.vm - it looks slightly different than the template vm-s.

Could you please change the above code according to the macros.vm?

Any idea?

Thanks in advance,

Rumi

1 answer

1 accepted

This widget could not be displayed.

Hi Rumi,

I have not tested it exaustivelly, but I think it would work. The original code into the macros.vm is

#set ($issueLink = "")
    #if ($issue)
        #set ($issueType = $issue.getIssueTypeObject())
        #set ($issueLink = "<a href='${baseurl}/browse/${issue.getKey()}'>#renderIcon(${issueType.iconUrlHtml} ${issueType.getNameTranslation($i18n)}) $textutils.htmlEncode($issue.getKey())</a>")
    #end

And the customized is

#set ($issueLink = "")
    #if ($issue)
        #set ($issueType = $issue.getIssueTypeObject())
			#if ( $issue.getProjectObject().getProjectCategory().getString("Test"))
			#set ($issueLink = "<a href='https://testurl/browse/${issue.getKey()}'>#renderIcon(${issueType.iconUrlHtml} ${issueType.getNameTranslation($i18n)}) $textutils.htmlEncode($issue.getKey())</a>")
			#else
	        #set ($issueLink = "<a href='${baseurl}/browse/${issue.getKey()}'>#renderIcon(${issueType.iconUrlHtml} ${issueType.getNameTranslation($i18n)}) $textutils.htmlEncode($issue.getKey())</a>")
			#end
    #end

I hope it helps.

Cheers

Hi Tiago,

thanks a lot!

Let me try..

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

144 views 2 0
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