Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Setting the value of a "Message Custom Field" (not for edit) by JavaScript

Chris K. December 13, 2014

I'm using a "Message Custom Field" and what I want to do is have it display the current issue's ID + Summary. If I use the below code in the CF description, it works fine if I'm setting just a regular single-line text field. However if change the custom field to the "Message Custom Field", it doesn't change the value.

<script type="text/javascript">
  summary = document.getElementById('summary');
  issue_key = AJS.Meta.get("issue-key");
  target = document.getElementById('customfield_10002');
  target.style.display = '';
  target.value=issue_key + " " + summary.value;
</script>

Do you change the value of a Message Custom Field differently than a regular custom field? That's the only thing I can think of. Any help would be greatly appreciated. Thanks!

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 14, 2014

Message custom fields do not have a value - they draw their data from the default value and then have nothing to display for the actual value - the velocity file basically just says "$default-value"

Injected Javascript is a clunky, messy and unmaintainable way to do anything with JIRA and should be avoided - stripping it all out is usually the first thing an experienced JIRA admin will do to an inherited system.  You should really use the functions the field provides - it supports velocity internally, so all you really need is to put "$issue.getKey() $issue.getSummary()" in the default value.

Chris Kast December 14, 2014

Thanks, NIc. Yeah, injecting JS wasn't my first choice...we're just using it as a stop-gap till we can create a proper plugin. Can you point me somewhere that shows the proper syntax for velocity? I tried putting exactly what you have above as the default value: $issue.getKey() $issue.getSummary() And it just displayed the above string literally. Thanks!!

Gary Bates March 27, 2019

Hi Nick,

I must have read a few hundred of your responses over the last couple of years as a JIRA admin, you're a bit of a ledge :)

I'm having the same trouble as Chris, those $ values are displayed literally and are not taken from the current issue dynamically.

Any clues? I've searched around for ages without success.

Gary

0 votes
Chris K. December 13, 2014

I put a simple "alert" box script in the Default Value field and the script ran fine so the JS is being called. I'm assuming then it's the way that I'm trying to set the value...

TAGS
AUG Leaders

Atlassian Community Events