Forums

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

Automation - Check if previous value is blank

Andy McCormick
March 28, 2023

It's quite simple to check if the current value of a field is blank. However, I'm trying to run automation only if the value was previously not empty. In this case the Due Date.  Am I missing something obvious? 

In the Issues Field Condition, you can only select the field as it currently is after the change. I tried using JQL with `{{fieldChange.from}} != ""` and `{{fieldChange.fromString}} != ""` which both resulted in errors. 

1 answer

1 accepted

2 votes
Answer accepted
Kristian Walker _Adaptavist_
Community Champion
May 21, 2018

Hi Randy,

The components field is an array so to set the value you require, you should use syntax similar to the example show below where you specify the component by its name using a name, value pair.

issueInput.fields.components = [[name: '<ComponentNameHere>']]

If this answer has solved your issue can you please accept it in order to mark this answer as correct for users who are searching for a similar issue.

Regards,

Kristian

Randy
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 Champions.
May 21, 2018

That did it.  Thanks!

E01807
April 17, 2019

Any idea how you do this so that you can add a new component without overwriting any components that are already there? I have a use case where I want to be able to add multiple components either through scripts or by the users.

Randy
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 Champions.
April 17, 2019

@E01807  you can read from the components field, add to the array, then set the array to the issueInput component field as Kristian showed above.

E01807
April 23, 2019

Thanks @Randy . I'm pretty new to this. Would it be possible for you to post a code snippet on how this might be achieved?

Randy
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 Champions.
April 23, 2019

This might work.  Note that it's untested.  Assumes Issue and issueInput are available in the script context as bindings

 

def newComponentList = issue.fields.components.clone()

newComponentList.add([name: 'New Component'])

issueInput.fields.components = newComponentList

Suggest an answer

Log in or Sign up to answer