Forums

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

How to detect 'invalid' fieldChange.fromString ?

Niklas Malmberg
Contributor
March 27, 2024

I have an automation doing recalculation of Task (Story) size when a child subtask is moved between different Tasks. This rule triggers on When: value change for Parent, and in this rule I can retrieve the "old" parent with fieldChange.fromString, and the new parent with fieldChange.toString (or from triggerissue.parent).
This works well for almost all cases when a subtask is moved between Tasks (or Stories). 

However, I've detected that when I create a new subtask in an existing Task, this also triggers the When: value change for Parent event (kind of surprisingly). But this time the fieldChange.fromString does not contain any old parent information (that part makes sense, since it's a subtask newborn in this Task, not forced to leave its previous parent).

However, my rule needs to detect this case too, to avoid crashing.
But I have not been able to figure out how yet.

The fieldChange.fromString is not null, that I have tested, did not work. It look more like it's an empty string (or invalid reference?). 

A simple rule to trigger this is:
Screenshot 2024-03-26_000098.pngJust open an existing Task, add a child issue (=subtask) and the result is this error:
  
Screenshot 2024-03-26_000099.png

Which is what I want to avoid, by detecting the lack of useful content in fieldChange.fromString When: value change for parent triggers, before I try to use it in the rule.

I hope you have some suggestions on how to write this test. 

1 answer

1 accepted

1 vote
Answer accepted
Michael Wohlgemuth
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 27, 2024

Greetings!

The fieldChange.fromString is not null, that I have tested, did not work. It look more like it's an empty string (or invalid reference?).

You got it already :D

A if block with a condition for "smart values" checking for "Empty" should work.

fieldchangefromempty.PNG

Niklas Malmberg
Contributor
April 4, 2024

Oh yes, there's the logic needed ! Many thanks @Michael Wohlgemuth 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events