Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Scriptrunner | Web-item | How to use custom variable in url of web-item?

Edited

How can i get or how must i set the variables to be available in a web-item url or in a raw xml? (Jira server)

test.PNG


 

1 answer

1 accepted

1 vote
Answer accepted
Helmy Ibrahim _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Nov 09, 2023 • edited

Hi @Markus W_ BENES,

This is currently not possible, and we do have a Feature Request raised for this: SRJIRA-2360

As a workaround, you can have the Web Item execute a Custom Rest Endpoint by providing its relative URL in the Link field. Then, you can do any custom scripting in the endpoint code and redirect the user to a dynamic URL, similar to the following example: Web Item (Redirect)

As an example, here is my Web Item configuration:

SS1.png

And here is my Rest Endpoint script:

import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate
import groovy.transform.BaseScript

import javax.ws.rs.core.MultivaluedMap
import javax.ws.rs.core.Response

import java.net.URLEncoder

@BaseScript CustomEndpointDelegate delegate

doSomething(httpMethod: "GET", groups: ["jira-administrators"]) { MultivaluedMap queryParams, String body ->

def myVariable = "Hello World"
def encodedString = URLEncoder.encode(myVariable)

Response.temporaryRedirect(URI.create("https://www.google.com/search?q=${encodedString}")).build()
}
Clicking on the Web Item will redirect me to a Google page with a searched query 'Hello World'.
I hope this helps!
Kind Regards,
Helmy

Thank you for this piece of gold.

Suggest an answer

Log in or Sign up to answer