How to invoke a library function from another library function (defined in another element)?
Question
Let's say I have Element1
including function f1
:
def f1() {
return 1
}
I tried to invoke f1
from f2
defined in Element2
. Both elements are in __LIBRARY__
logic.
def f2() {
return lib.Element1.f1() + 1
}
and I got an error "No such property: lib".
I also tried:
def f2() {
return Element1.f1() + 1
}
which works in a regular logic but in the library I'm getting error "No such property: Element1".
I'm calling f2
in this way:
lib.Element2.f2()
Element1 is defined before Element2.
What is wrong? Is there any way to call f1
from f2
?
Answer
You have to call f1
through libs.__LIBRARY__.Element1
:
def f2() {
return libs.__LIBRARY__.Element1.f1() + 1
}
Related content
How to Reference Constant (Static) Member in Groovy Library
How to Reference Constant (Static) Member in Groovy Library
More like this
Predefined Variables
Predefined Variables
More like this
Life cycle of an InMemory table in a PA Calculation
Life cycle of an InMemory table in a PA Calculation
Read with this
How Timeouts Work
How Timeouts Work
More like this
How do I use Datamart IF condition in SQL Expression?
How do I use Datamart IF condition in SQL Expression?
Read with this
Found an issue in documentation? Write to us.