Sometimes it may be neccessary to use the same formulas or pieces of formulas (code snippets) multiple times. In such cases it's convinient to have them in one place. To do that it's possible to write kind of Groovy library and include it in formulas.

To do that you have to have an extension of any kind and upload a groovy class under Text and binary resources. The class has to have a structure like this:

class MyFunctionsClass {
	def customFunction() {
		return "Hello world!"
	}
}

and the filename has to match the class name, in this example case it'd be "MyFunctionsClass.groovy".

Let's assume that the extension where this groovy file is uploaded is called "My Functions Extension". Then it's possible to use the defined function in any formula like this:

//importFromExt(My Functions Extension,MyFunctionsClass)
return MyFunctionsClass.customFunction()

KPI label with Formula indicator containg above code will then produce:

  • No labels