We need to provide links to a different system based on the value of a field on each issue. The particular use case is to link the atlassian jira issues to work items in our TFS repository.
I want to be able to have a link on each issues that concatenates our tfs url (ex https://tfshost/tfs?id=) and the value of the TFS Work Item field (ex 123) so that the end result is a clickable link that sends the user to http://tfshost/tfs?id=123.
Any ideas?
Hi Felix,
I hate to say it every time, but unfortunately I am afraid this type of customizations are to advanced for a jira ondemand instance. You need at least jira downloaded so you can install plugins like Scriptrunner or upload your own plugins with custom functionality.
Hi Felix,
Although the solution cannot be implemented in JIRA on-demand, I think it is still interesting to share my solution:
1) Install the Scriptrunner plugin
2) Create a custom field named "TFS Work Item" of type Text Field (or any type you want)
3) Create a custom field named "TFS Url" of type Scripted Field (Installed by the scriptrunner plugin)
4) Goto Admin > Addons > Scripted Fields and locate your scripted custom field. Next click the Edit link to open edit mode. In the script field paste the following code:
import com.atlassian.jira.ComponentManager; import com.atlassian.jira.issue.CustomFieldManager; import com.atlassian.jira.issue.fields.CustomField; import com.atlassian.jira.issue.IssueManager; import com.atlassian.jira.issue.Issue; import com.atlassian.jira.issue.MutableIssue; CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager(); CustomField tfsCustomField = customFieldManager.getCustomFieldObjectByName( "TFS Work Item" ); String url = "http://tfshost/tfs?id=" + issue.getCustomFieldValue(tfsCustomField); return "<a href=\"" + url + "\">" + url + "</a>";
and make sure the HTML template is selected. This renders the value returned by the script as HTML (in this case a hyperlink).
5) Add the TFS Url to all the screens were it should be visible
This will be the result:
The advantage of using the Scriptrunner plugin is that the scripted field will be updated automatically whenever an issue field is updated. Changing the TFS Work Item field also updates the url.
This script does not check for null-values, but that test can be easily added :-)
Hope this helps?!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Benji,
How do you do the "and make sure the HTML template is selected. This renders the value returned by the script as HTML (in this case a hyperlink)."
In my Field configuration, I don't have the Renderers option on the scripted field just like some other fields...
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If someone would like to use Benjis code on JIRA 7, you have to modify it as shown below:
import com.atlassian.jira.component.ComponentAccessor; import com.atlassian.jira.issue.CustomFieldManager; import com.atlassian.jira.issue.fields.CustomField; import com.atlassian.jira.issue.IssueManager; import com.atlassian.jira.issue.Issue; import com.atlassian.jira.issue.MutableIssue; CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager(); CustomField tfsCustomField = customFieldManager.getCustomFieldObjectByName( "TFS Work Item" ); String url = "http://tfshost/tfs?id=" + issue.getCustomFieldValue(tfsCustomField); return "<a href=\"" + url + "\">" + url + "</a>";
#ComponentAccessor
best regards,
Anton
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.