I have a Custom web item and it must open the user's mail client using the mailto: link. I am able to pass many of the values in the link, but the one that is eluding me is the value in the custom field called "E-Mail".
I know ${issue.get('E-mail')} will not work in SR - it is a desperate attempt at using JMWE notation after everything else has failed.
How do I get the value of the 'E-mail' field?
image2017-1-18 18:36:32.png
Velocity is just not flexible enough to handle that syntax.
You can do it by using a ContextProvider to make a variable called $email available in the velocity context.
You can see how to do that in this example: https://answers.atlassian.com/questions/43888344
issue.getCustomFieldValue
is the method you're after. Using it in the link there is likely to be a bit unwieldy, but it should be possible inside of closure braces.
issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.customFieldManager.getCustomFieldObjects(issue).find{it.name == "My Custom Field"})
Full disclosure: I've not tested that, nor am I 100% certain that it's necessary to fully qualify the ComponentAccessor class package.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jonny, I had tried this before, but it does not work.
Using the following as a link works perfectly, (but obviousy there is no email address):
mailto:?subject=[JIRA] (${issue.getKey()}) ${issue.summary}&bcc=${issue.projectObject.email}
Using the following:
mailto:${issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.customFieldManager.getCustomFieldObjects(issue).find{it.name == "E-mail"})}?subject=[JIRA] (${issue.getKey()}) ${issue.summary}&bcc=${issue.projectObject.email}
causes an error. Log file entries for the error start with:
2017-01-18 23:25:01,499 http-nio-127.0.0.1-8080-exec-19 uri:/secure/AjaxIssueAction!default.jspa username:cnielsen ERROR cnielsen 1405x55561x1 146b1tl 172.16.0.1,127.0.0.1 /secure/AjaxIssueAction!default.jspa [velocity] Parser Exception: getEncodedBodyFromContent 2017-01-18 23:25:01,501 http-nio-127.0.0.1-8080-exec-19 uri:/secure/AjaxIssueAction!default.jspa username:cnielsen ERROR cnielsen 1405x55561x1 146b1tl 172.16.0.1,127.0.0.1 /secure/AjaxIssueAction!default.jspa [velocity] org.apache.velocity.runtime.parser.ParseException: Encountered "{" at line 1, column 135.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.