Forums

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

Clear linked issues using Behaviours using setFormValue()

Steven Mustari
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.
June 18, 2020

I'm trying to clear a form value from the linked-issues field using behaviours.

I've tried the following three ways and none seems successful:

def rt = getFieldById(getFieldChanged())
def links = getFieldById("issuelinks")
def linkType = getFieldById("issuelinks-linktype")
def linkIssues = getFieldById("issuelinks-issues")

def rtValue = rt.getValue()?.toString()

switch(rtValue) {
case "Duplicate":
links.setHidden(false)
linkType.setFormValue("duplicates").setReadOnly(true)
linkIssues.setRequired(true)
break

default :
links.setHidden(true)
linkType.setFormValue(-1).setReadOnly(false)

//None of these seem to work correctly//
linkIssues.setRequired(false).setFormValue("") <--- FIRST WAY
linkIssues.setRequired(false).setFormValue(null) <- SECOND WAY
linkIssues.setRequired(false).setFormValue(-1) <--- THIRD WAY
break
}

Any assistance would be appreciated!

Regards,
Steven Mustari

3 answers

0 votes
Azfar Masut
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.
April 26, 2022

from scriptrunner support:

This is a bug: SRJIRA-5851

linkIssueField.setDescription("<script>AJS.\$('#issuelinks-issues').val(''); AJS.\$('#issuelinks-issues-multi-select .representation .items em.item-delete').click()</script>")

Instead of setFormValue("") and all the other options I've tried, we're using JavaScript to remove the linkIssueField value.

0 votes
vishal goyal September 13, 2021

Need a help, is there a way to restrict the search also for this issue link field, lets say i want the issue to come up for one project only which must be available for users to link?

 

Regards

Vishal Goel

0 votes
Mathis Hellensberg
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.
June 18, 2020

Hi @Steven Mustari 

From which screen are you trying to accomplish this?

Steven Mustari
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.
June 18, 2020

Hello @Mathis Hellensberg

From a transition screen. Everything is working correctly except for clearing the value of "linkIssues".

The only problem are the following lines:

linkIssues.setRequired(false).setFormValue("")
linkIssues.setRequired(false).setFormValue(null)
linkIssues.setRequired(false).setFormValue(-1)

Regards,
Steven Mustari 

Mathis Hellensberg
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.
June 18, 2020

What kind of field is linkIssues? :)

Steven Mustari
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.
June 19, 2020

@Mathis Hellensberg

It's half of the composite system field "issueLinks".

Screen Shot 2020-06-19 at 2.00.09 PM.png

 

It can be broken down into editing either of the two sub-fields:

issueLinks-linktype:

Screen Shot 2020-06-19 at 2.00.09 PM.png


issueLinks-issues:
(This is the field I'm trying to clear)
Screen Shot 2020-06-19 at 2.00.09 PM copy.png

 

Here is a link to the documentation explaining this.

Thank you for your help,
Steven Mustari

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.5.1
TAGS
AUG Leaders

Atlassian Community Events