Question

Following is my code:

HTML:

<p1>Please download the following document:</p1>
<br>
<a id="text" href="https://www.website">[YOUR DOWNLOADLINK WILL BE SHOWN HERE AFTER SELECTING A MODULE]</a>
<br>
<p2> and attach it to your issue.</p2>

 

JS:

if(JIBROK_MESSAGE_FIELD_CONTEXT == "CREATE_SD"){
require(['jquery'], function($) {

$('#customfield_10406').on('change', function(){

meineFunktion();
})

function meineFunktion(){
var v = document.getElementById("customfield_10406");
var strUser = v.options[v.selectedIndex].text;
var str = strUser.replace(" ", "_");
str = str.replace("/", "_");

$('#text').attr("href", "https://www.website/downloads/dokumente/" + str);
$('#text').text("https://www.website/downloads/dokumente/" + str);
}
})
} else if(JIBROK_MESSAGE_FIELD_CONTEXT == "VIEW_SD"){

} else {

}

 

As follows are the visual effects of the field: 

 

Creating issue(the Downloadlink field):

This is when the screen loads:

image.png

This is when you change the input in "Modulauswahl":

So the Function is as wished to this point. The Problem occures in the "view issue screen" on the customer side:

image.png

Initially, there is only a subtle change in the spacing between the fields, where one could expect the messagefield:

But after anything is done to the issue (eg. commented or statuschange from the customer view screen, following happens, even though I tried specifying in the code, that nothing is to happen on the "view issue" screen:

image.png
else if(JIBROK_MESSAGE_FIELD_CONTEXT == "VIEW_SD"){

} else {

 

image.png

I tried it also just without the else, if in the code but it didn't change anything.


Response

Please tell me which version of the plugin are you using?

Also by the screenshot, you are using Refined for Jira.

"Create issue" screen - you really need to track the change event. But the portal has a problem that stands above - the initialization of your js.

The latest version of the plugin allows you to implement such dynamics without writing JavaScript at all: https://jibrok.com/docs/message-field/dynamic-templates/

#set($cfSelect = 10302)
#set($text = "[YOUR DOWNLOADLINK WILL BE SHOWN HERE AFTER SELECTING A MODULE]")#set($href = "")

#if($cfValues.getFromForm($cfSelect)) 
    #set($text = "https://www.website/downloads/dokumente/" + $cfValues.getFromForm($cfSelect).value.replace(" ", "_").replace("/", "_")) 
    #set($href = "https://www.website/downloads/dokumente/" + $cfValues.getFromForm($cfSelect).value.replace(" ", "_").replace("/", "_"))
#end

<p1>Please download the following document:</p1>
<br>
<a id="text" href="$href">$text</a>
<br>
<p2> and attach it to your issue.</p2>

 

Screenshot how to set up. Note that you can manage the terms here: On which screens to display.

 

And some final screenshots.

Create:

View: