Skip to main content
6-Contributor
February 27, 2025
Question

How to count the number of ancestors of working item?

  • February 27, 2025
  • 1 reply
  • 750 views

Hi dear Community,

 

I would like to check, how many ancestors have the working item, using computed field.

 

I found some information about function "ancestors()" , but it didn't work in my case.

 

I have the codeBeamer version 2.1.0.0 (postgresql).

 

Thank you in advance!

1 reply

12-Amethyst
March 11, 2025

Hi @vjub58 ,

 

When you say the ancestors() function did not work for you, could you explain a bit further. i.e. what are you expecting as a result, and what was ancenstors() giving you when you tried to use it?

vjub586-ContributorAuthor
6-Contributor
March 11, 2025

Hi @tymorrow ,

 

I'm expecting the ancestors() function returns a list of all item's ancestors, and size(ancestors()) returns the size of this list, i.e. the number of ancestors of this item.

 

When I try to use the ancestors() function in computed field, the expression is not evaluated properly and error message (like "ancestors()" is unknown") has been appeared.

12-Amethyst
March 11, 2025

Hi @vjub58,

 

I've tried this function in a new default Codebeamer project, and I see the same error. This does not appear to be an out-of-the-box function. I am actually seeing similar results when I attempt to use "size(ancestors())".

 

You can use "this.parent" to retrieve the first item up in the hierarchy, though you need to write some creative recursion for this to pull up a full list of ancestors. Please review the supported and available functions here: https://codebeamer.com/cb/wiki/25722#section-Functions