I have a requirement as following
The user will enter a number in the custom field which is validated to enter number only while creating a ticket. Once ticket gets created I need that number to get added to the URL so that user clicks that link and it takes to the appropriate page.
Eg: In a different enterprise system, there is a numeric id for a ticket, and that numeric id is entered in Jira, I need JIRA custom field which enables users to input that number and that field data should convert into URL like http://abcdef.com/nbvj/1234 in ticket view so that user gets direct to that page when clicked.
Am new to JIRA scripting and am not sure where to add the script and what to code. I'm a beginner so any help is appreciated
As I think you have already worked out, I would probably want to do this as a "scripted field" in ScriptRunner.
There's quite a lot to do here for a first-time user, so I will try to be brief, and expect questions if I am too brief, or assume things you don't know!
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
CustomField customField = customFieldManager.getCustomFieldObjectByName("Reference entry")
def theId = (String) issue.getCustomFieldValue(customField)
return '<a href="http://abcdef.com/nbvj/' + theId + '>See item ' + theId + '</a>'
Thank you for the answer.I have couple questions, here it goes
In the line
def theId = (String) issue.getCustomFieldValue(customField), I think I should use custom field number of(reference URL) there in order to pull the data, am I correct? or field being scripted field it automatically pulls data?
and what is See item in return statement? maybe a dumb question but trying to understand the code.
A scripted field is aware of the issue it is running for. You don't need to think about it, you can just use the issue object like my code does.
The customField is worked out by the line above it in the script.
The "see item" is some text I added as an anchor for the url field, so you see something like "See item: 12345" instead of http://abcdef.com/nbvj/12345 - totally optional and cosmetic.
We're looking for participants for a workshop at Atlassian! We need Jira admins who have interesting custom workflows, issue views, or boards. Think you have a story to sha...
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!
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