How to call a user function on parent issue in a Jira Structure formula?

LaBulle22 December 7, 2022

Hello,

With Expert Jira structure language, I can write following code to check status of parent current issue:


if parent{status} = “Open”:
    …

Suppose now that the test is much more complex and I prefer writing a user function:

with cond = status = “Open” and … :

My problem is that I fail calling user function "cond" on parent issue ☹. Do I need to pass it as a parameter (how to do) or is it possible to call "cond" in parent issue context?

Thanks for your help.

LaBulle22

2 answers

1 accepted

0 votes
Answer accepted
David Niro
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 7, 2022

Hello @LaBulle22 ,

Could you describe what you are trying to do, in full?  Understanding the use case will help in determining the best approach.

Best,
David

David Niro
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 7, 2022

Hi @LaBulle22 ,

Thank you for the additional detail!

The format for creating a user function is described here.  Line 1 in the example is the format for the function and Line 2 is that function in use.

It's very similar to writing a local variable where you start the function with with and end it with :

Possibly what you were running into if you were trying to do PARENT{cond} is that local variables cannot be used within Aggregate Functions.  You would need to write the entire condition within PARENT{}.

If you're an Expr newbie, you may be interested in our Expr 2.0 Bootcamp Session I and Session II.  They are a great starting place!

Please let me know if this helps!

Best,
David

LaBulle22 December 8, 2022

Hi David,

Thanks for all this information. I knew these 2 Bootcamp sessions that are a very good way to get started indeed.

OK, I understand one cannot use a local variable inside an aggregate function or pseudo aggregate function like "parent".

Seems there is neither no way to pass an issue as a parameter to a local function. We could imagine that following code could be possible after all ;-):

with get_summary(issue) = issue.summary:
get_summary(<something that returns parent issue>) 

But it seems that what I'd like to achieve is possible by using a Formula: say that Formula "KeyF" simply returns the issue key (or something much more complex). It's then possible to write:

parent{KeyF} or parent#level=-2{KeyF} 

to get the parent key or the grand-parent key of the current issue. Is that a normal use of Expr language or a dirty hack?

I've an additional question (that could maybe deserve a new thread, please tell me). Is there any technical articles that would go beyond the Formula & Expr reference manual and that would explain how all that works (high level view) and give some tips to the reader to optimize Formulas execution time (my current concern)?

Regards,
LaBulle22

Like David Niro likes this
David Niro
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 8, 2022

Hi @LaBulle22 ,

That would be normal use of Expr.  We have some documentation that describes Expr in some more detail here.

Please also feel free to contact our support team directly via support@almworks.com or through our customer portal support.almworks.com!

Best,
David

LaBulle22 December 8, 2022

Hi David,

OK, I will contact ALM Support if need be. Thanks a lot for all the time you spent to help me  :-).

Regards,
LaBulle22

Like David Niro likes this
David Niro
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 8, 2022

You are very welcome @LaBulle22 !  I'm happy to help!!

0 votes
LaBulle22 December 7, 2022

Hi David,

In substance, I’d like to define a boolean user function (i.e. "with myuserfunction = ... :") that I could call either on parent issue or on grand-parent issue depending on the type of the current issue.

I could workaround my problem by writing parent{<attribute>} or parent#level=-2{<attribute>} depending of the type of the current issue but as the whole test is made of a combination several tests, I’d like to get a more elegant approach by writing code once and then call it either on parent or grand-parent.

I must say that I'm a "Expert coding language" newbie!

Regards,
LaBulle22

Suggest an answer

Log in or Sign up to answer