Hyperlink with scriptrunner

Ireen Klein_Actonic August 31, 2018

Hi,

our customer want to use behaviours to prepopulate a hyperlink in the description field.

Please can you help with the code?

def desc = getFieldById("description");
def text = "hier";
def hyper=text.link("http://google.com");

def defaultValue ="""Instruktionen sind """+ hyper+""" zu finden""";
if (! underlyingIssue?.description) {
desc.setFormValue(defaultValue)
}

I get an error on line 3: "Cannot find matching method" and no output

 

2 answers

0 votes
Srinath Reddy Pinappu May 2, 2023

@Mark Markov : If we wanted to have 2 hyperlinks in description(Google and yahoo.com) field does it work ? if so could you please help on that ?

0 votes
Mark Markov
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.
September 3, 2018

Hello @Ireen Klein_Actonic

You should do it via html tags, like this

def desc = getFieldById("description");
def hyper="<a href=\"http://google.com\">google</a>";

def defaultValue ="""Instruktionen sind """+ hyper+""" zu finden""";
if (! underlyingIssue?.description) {
desc.setFormValue(defaultValue)
}
Ireen Klein_Actonic September 7, 2018

Hello @Mark Markov,

thx for your answer. Unfortunately it doesn't work.

The output/the prepopulated text in description field is:

Instruktionen sind <a href="http://google.com">google</a> zu finden.

 

What have I to change?

Mark Markov
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.
September 7, 2018

Oh, its description.

Try this

def desc = getFieldById("description");
def hyper="[google|http://google.com]";

def defaultValue ="""Instruktionen sind """+ hyper+""" zu finden""";
if (! underlyingIssue?.description) {
desc.setFormValue(defaultValue)
}

And make sure that wiki render is enabled.

How to work with wiki markup.

Like Ahmed Arslan likes this
Ahmed Arslan August 5, 2021

@Mark Markov , It worked for me. Thanks

ChristopherChilds November 5, 2021

@Mark Markov

Do you know if there is an alternative way? as we are not allowed to enable wiki render because of a security risk

Ahmed Arslan November 7, 2021

Hi @ChristopherChilds  you can use the field description to have the URL added in field's description IMO.

Like ChristopherChilds likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events