The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

html script to get the custom field value

Shilpa Sanil
Contributor
August 3, 2021

Hi,

 

I want to set a link as a Message custom field value in Jira. So i want to get the value of a custom field in this script. How can i get it as an html script.

Thanks

Shilpa

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

1 vote
Leo
Community Champion
August 4, 2021

Hi @Shilpa Sanil,

I worked with javascripts long back, not in recent days. you can try out ".value" or below code to fetch value of custom field or any other field(s)

target = document.getElementById('customfield_10000');

target.value 

 Hope this helps

 

Regards,

Leo

0 votes
Charlie Misonne
Community Champion
August 3, 2021

Hi Shilpa,

With HTML script I assume you mean javascript?
You could use javascript to fetch the custom field value via the REST API of Jira. But if I'm not mistaken custom JS does not work properly anymore in more recent version of Jira. I haven't tried it in a while.

Is there any reason you need to do this in a message custom field? Because I'd rather use a scripted field with scriptrunner. Of course that app is not free.

Shilpa Sanil
Contributor
August 3, 2021

Hello Misonne,

 

Am trying a html script for adding a default value for a Custom Message Field. eg would be like this:

 

if(document.getElementById("customfield_11370-val") != 'undefined' && document.getElementById("customfield_11370-val") != null){
var key = JIRA.Issue.getIssueKey();

var htmlVar = "<a target=\"_blank\" href=\'"+"http://example.com/"+key+"'>"+"http://example.com/+key+"</a>";

document.getElementById("incDiv").innerHTML = htmlVar;
}

 

Here am taking Jira issue key value like wise i need to fetch a customfield value.

 

Thanks

Shilpa

Charlie Misonne
Community Champion
August 4, 2021

Ok I haven't used that method myself. I think you should look into what @Leo replied.

DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events