Custom Field in ScriptRunner's Script Fragments (Custom Web Item)


I have a user requirement that utilizes the custom web item feature provided by scriptrunner. I have a custom field that needs to be added as a link, for example: The user enters something in the "Shipping #" custom field and after creation the Script Fragments piece adds a link in the operations-top-level. I need assistance with the link. Can someone please help. I cannot access the value of the custom field.Picture2.png

1 answer

1 accepted

Hi Eric, 

You cannot get the value of the scripted field in the link field. What you can do tho, is to create a rest endpoint that will redirect you somewhere esle, there is a similar example in the documentation.

So in your case you have to create a scripted rest endpoint and the script for this endpoint will be 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.sal.api.ApplicationProperties
import com.atlassian.sal.api.UrlMode
import com.onresolve.scriptrunner.runner.ScriptRunnerImpl
import groovy.transform.BaseScript


@BaseScript CustomEndpointDelegate delegate

def applicationProperties = ScriptRunnerImpl.getOsgiService(ApplicationProperties)
def issueManager = ComponentAccessor.getIssueManager()

buttonLink(httpMethod: "GET") { MultivaluedMap queryParams ->

def issueId = queryParams.getFirst("issueId") as Long

if (!issueId)

def issue = issueManager.getIssueObject(issueId)

def cf = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("TextFieldA")
def value = issue.getCustomFieldValue(cf)

def baseUrl = applicationProperties.getBaseUrl(UrlMode.ABSOLUTE)

Now in the link field in your button you should vae something like


You just have to make sure that you select a setcionf for your itam that will have the issue object on it. For example 


Hope that does the trick.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

97 views 0 5
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