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

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,462,968
Community Members
 
Community Events
176
Community Groups

Update Custom Field value from Script Runner Dialog

I'm new to Script Runner. Now I have created a HTML dialog box with Fragments (to open it) and REST Endpoints script. I show several custom field values from the ticket in the dialog box and also check boxes and drop downs customized for the dialog box and further usage. Now there are two use-cases of this dialog box. One is to send data to a 3rd party, and another is to update a custom field (textfield). The user should be able to add (if the custom field was not filled with a value in the ticket) or update the custom field. To save the value I have created a HTML Save-Button and a click event with javascript. The click event is working. But how can I add (or update) the value to the custom field in the ticket? I don't see a way doing this within the JS click event. Is this even possible? Or is my approach wrong? Thank you so much for advises on how to solve this problem.

Cheers Nicole

2 answers

1 accepted

1 vote
Answer accepted

In your save button click event, call the built-in jira rest API with AJS.$.ajax() and supply the value for your custom field.

Something like:

var issueKey = JIRA.Issue.getIssueKey()
var valueFromForm = '' //get the value from your form, perhaps using AJS.$('selector')
AJS.$({
type:"PUT",
dataType:"json",
contentType: "application/json",
url: `/rest/api/latest/issue/${issueKey}`,
data: JSON.stringify({fields:{customfield_xxxx:valueFromForm}}),
});

Hi @Peter-Dave Sheehan I'm trying the same stuff. But when I execute the rest end point it loads to anther page. Is there any way the dialog could be displayed like a pop up?

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events