Copy URL from Weblink field to Comment and/or Label fields (make weblink searchable)

Nicholas Cooprider February 23, 2024

I have a bunch of tickets with Weblinks in the Weblink Field and I need to copy these links to either a Comment and/or the Label field of the tickets where they appear in order to make them text searchable via JQL.

I have access to Scriptrunner which I see can copy from custom fields to other fields, but I can't see a way for it to copy from the Weblink field to Comments or Labels since these are not custom.

Also, the Weblinks in question are to tickets in another JIRA instance, so if putting these in Labels, it would be ideal if we could truncate the URL to just the ticket Key (e.g. truncate from https://mycompany.atlassian.net/browse/FAKE-5114 to just FAKE-5114 in the Labels field).

The ultimate goal is to make the Weblink searchable, so I am also open to other suggestions.

Thank you in advance for any assistance.

1 answer

1 accepted

1 vote
Answer accepted
Kristian Walker _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.
February 26, 2024

Hi Nicholas,

I can confirm it is possible to copy the value from a field to the comments field using ScriptRunner for Jira Cloud.

You would need to write a script which, first of all gets the issue and extracts the value from the WebLinks field to a variable.

You would then be able to set this in the comments field of the issue using the Add Comment Rest API, and I can confirm we have an example of using this API here to set a comment that you can use as a reference.

Alternatively, you can set a label field with the value from the WebLinks field by calling the Edit Issue API and passing in the array of labels to set. We have an example of setting the label field here that you can use for reference.

If you need to truncate the URLs to get the issue key, then you can do this in Groovy, and the example code here on line shows how to do this.

Finally, if you need to copy values for multiple issues, then you can do this by calling the Search for issues API and running the code to update each issue returned by the JQL search. We have an example of doing this here.

I hope this information helps.

Regards,

Kristian

Nicholas Cooprider February 27, 2024

Thanks for the response.

Unfortunately where I am getting hung up is figuring out the FieldID for Web Links, which as far as I can tell is not a custom field. I used the "Get Issue Fields" script and input a valid issue ID and while I get results returned, I can't find anything for the Web Link field specifically.

Any ideas would be greatly appreciated.

The exact script I used which returned results, but not for the field I am looking for is:

def issueKey = 'ST-5055'

def result = get('/rest/api/2/issue/' + issueKey)
.header('Content-Type', 'application/json')
.asObject(Map)
if (result.status == 200){
return result.body.fields
} else {
return "Failed to find issue: Status: ${result.status} ${result.body}"
}

 

Edit: I also looked through the Custom Fields in JIRA just in case and didn't see it there either.

Kristian Walker _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.
February 28, 2024

Hi Nicholas,

Can you please share a screenshot of the weblinks field on an issue in your instance so we can see this?

Also, can you please confirm if the project type you are using is a team-managed project or a company-managed project?

Regards,

Kristian

Like Nicholas Cooprider likes this
Nicholas Cooprider February 28, 2024

Screenshot below.

It's a company managed project.

Web Links.JPG

 

 












 

Nicholas Cooprider March 8, 2024

@Kristian Walker _Adaptavist_any chance you can take a look at the requested info I provided to see if you can help move this along? I would greatly appreciate any assistance.

Thank you.

Kristian Walker _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.
March 8, 2024

Hi Nicholas,

It looks like this field is provided by an external plugin, so I dont believe scriptrunner will be able to access it as its not a standard Jira field.

Regards,

Kristian

Like Nicholas Cooprider likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events