Forums

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

How to clear Epic Link Form Field with Scriptrunner Behaviours

Erik Buchholz
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.
March 17, 2021 edited

I want to set the epic link to an issue key from an other form field (scriptrunner issue picker).

This is no problem so far, but how do I clear the epic link form field, if the other form field is cleared? Empty string, -1 and null are not working.

def epicLink = getFieldByName('Epic Link')
def issuePicker = getFieldByName('Issue Picker')
def issueKey = issuePicker.getValue()
if (issueKey) {
epicLink.setFormValue(issueKey)
}
else {
epicLink.setFormValue('')
}

I thought the approach to use a issue picker field, would be a solution to my original problem.

Is it possible to restrict the epics I can choose in epic link.

I want to restrict the choices depending on the input on that issue. With the issue picker field I found a solution to do that. But I don't want epic link to remain, when I clear issue picker field.

Probably I could do it with the issue picker field and a listener to watch all changes of that issue picker field, but that solution is hard to service if anything goes wrong or needs to be changed.

1 answer

1 accepted

1 vote
Answer accepted
Leo
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 18, 2021

Hi @Erik Buchholz,

How about passing "null" value to the form field

getFieldByName("Epic Link").setFormValue(null) 

This seems to be working for me

 

BR,
Leo

Erik Buchholz
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.
March 18, 2021

Hi @Leo ,

I will try in a simple example. Perhaps my complete code is to complex.

Regards,
Erik

Erik Buchholz
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.
March 18, 2021 edited

Hi @Leo ,

I removed all other code from my behaviour and tried your code line in field script and initializer script, but in both cases only the text in summary field gets selected but epic link remains.

I see that I have the right field, because with setDescription I can change the description and so on. Only clearing isn't working.

I thought about browser problems, but it's the same in firefox and edge...

Regards,
Erik

Leo
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 18, 2021

You mean clearing epic link field value is not working? can you pass me your code

Erik Buchholz
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.
March 18, 2021

Hi @Leo ,

I used your code to be sure, that there isn't anything disturbing.

getFieldByName("Epic Link").setFormValue(null)

To be sure that I still have the right field I added a discription.

def epicLink getFieldByName("Epic Link").setFormValue(null)
epicLink.setDescription("Test")

The field was read only but I removed that too.

Perhaps I should contact Adapavist support. Perhaps they can see something in the logs or configuration, I don't see.

Regards
Erik

Erik Buchholz
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.
March 23, 2021

Hi @Leo ,

you're right. It should work and it works now. There was a bug with epic link in scriptrunner that is fixed with scriptrunner 6.15. For more information see https://productsupport.adaptavist.com/browse/SRJIRA-2664

Thanks to Adapatvist support for giving me this hint.

Regards
Erik

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Atlassian Community Events