Using ScriptRunner to get the value entered in a scripted field.

I would like to transform the text inputed into a scritped field to be transformed into a hyperlink based on what is inputed.

 

So far I have,

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager


CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
document_id = customFieldManager.getCustomFieldObjectByName('Document_ID');

//return the full href:
DOCUMENT_ID = issue.getCustomFieldValue(document_id);
return '<a href="http://server:port/object/Issue/' + DOCUMENT_ID + '">' + DOCUMENT_ID + '</a>'

This does not work, however.

2 answers

1 accepted

Hello Brian. 

We are happy to take your question here. We ran your script on our test servers and we see it working fine. You have not given us your output, so we do not know what part does not work.

We guessed that maybe you are not setting the scripted field template as a HTML, but as plain text. If you set your script like you see in the picture below:

Screen Shot 2017-04-06 at 10.45.12.png

It should work as you intend. 

Thank You, I forgot the 'def' infront of the document_id.

0 vote
Ann Worley Atlassian Team Apr 05, 2017

Even though Scriptrunner is a plugin, since you are working on some code, I wager the Developer Community will be of more help:

Atlassian Developer Community

 

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Tuesday in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

115 views 0 4
Read article

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