Show / Hide Table of Contents

Class StatLib

Class for using the Service statistics library.

Syntax

Constructors

StatLib()

Initializes a new instance of the StatLib class.

Declaration
StatLib

Methods

addAggregate(Integer,Integer,String,String,Integer)

Adds an aggregate function to the specified group

An aggregate function is a function that is calculated for all values for a given column in a group. For example, the average response time for each category.
Declaration
Void addAggregateStatLib.addAggregate(Integer groupColumn, Integer column, String name, String type, Integer decimals, Integer uniqueColumn)
Parameters
Type Name Description
Integer groupColumn

The column used for grouping.

Integer column

The column used for the calculation.

String name

The name of the calculated variable in the Parser or StatResult

String type

The type of function.

Integer decimals

The number of decimals to use in the calculated value.

Returns
Type Description
Void
Remarks

Available functions:

  • Count
  • Sum
  • Avg
  • Max
  • Min

addAggregate(Integer,Integer,String,String,Integer,Integer)

Adds an aggregate function to the specified group

An aggregate function is a function that is calculated for all values for a given column in a group. For example, the average response time for each category.
Declaration
Void addAggregateStatLib.addAggregate(Integer groupColumn, Integer column, String name, String type, Integer decimals, Integer uniqueColumn)
Parameters
Type Name Description
Integer groupColumn

The column used for grouping.

Integer column

The column used for the calculation.

String name

The name of the calculated variable in the Parser or StatResult

String type

The type of function.

Integer decimals

The number of decimals to use in the calculated value

Integer uniqueColumn

The value is only calculated for the rows which have a unique value in this column.

Returns
Type Description
Void
Remarks

Available functions:

  • Count
  • Sum
  • Avg
  • Max
  • Min

addCallback(Integer,String)

Adds a callback. A callback is a PARSER-snippet that will be executed for the given column for each row.

Declaration
Void addCallback(Integer column, String script)
Parameters
Type Name Description
Integer column

The column for which this callback should be executed.

String script

The Parser code to execute.

Returns
Type Description
Void
Remarks

This is an old method. Use StatResult and iterate instead.

addGroup(Integer,Bool)

Adds a group to the StatLib instance. A group is a subset of the results that have a common value for a given column. Aggregate values can be calculated for groups, for example, the average response time per category.

Declaration
Void addGroup(Integer column, Bool desc)
Parameters
Type Name Description
Integer column

The column to used to identify the groups

Bool desc

Sort order. True = descending, otherwise ascending.

Returns
Type Description
Void

addGroup(Integer,Bool,Bool)

Adds a group to the StatLib instance. A group is a subset of the results that have a common value for a given column. Aggregate values can be calculated for groups, for example, the average response time per category.

Declaration
Void addGroup(Integer column, Bool desc, Bool compareAsNumber)
Parameters
Type Name Description
Integer column

The column to used to identify the groups

Bool desc

Sort order. True = descending, otherwise ascending

Bool compareAsNumber

True if the value is a number and you want numeric sorting/grouping.

Returns
Type Description
Void

dropOrder()

Calling this function will make the StatLib instance skip sorting the results in the groups.

Declaration
Void dropOrder()
Returns
Type Description
Void

execute(Parser)

Runs the query and aggregations and stores the results in a Parser

Declaration
Void execute(Parser parser)
Parameters
Type Name Description
Parser parser

The instance to store the results in.

Returns
Type Description
Void
Remarks

You can choose between storing in a Parser or a StatResult by passing the appropriate object.

execute(StatResult)

Runs the query and aggregations and stores the results in a StatResult

Declaration
Void execute(StatResult result)
Parameters
Type Name Description
StatResult result

The instance to store the results in.

Returns
Type Description
Void
Remarks

You can choose between storing in a Parser or a StatResult by passing the appropriate object.

setGenericSearch()

Use the given GenericSearch entry as query (instead of SQL string).

Declaration
Void setGenericSearch(GenericSearch gs)
Parameters
Type Name Description
gs

The GenericSearch entry to use.

Returns
Type Description
Void

setName(String)

Sets the name for the instance. The name is used to prefix the result in the Parser.

Declaration
Void setName(String name)
Parameters
Type Name Description
String name

The name for the instance.

Returns
Type Description
Void

setSearchEngine()

Use the given SearchEngine entry as query (instead of SQL string).

Declaration
Void setSearchEngine(SearchEngine se)
Parameters
Type Name Description
SearchEngine se

The SearchEngine entry to use.

Returns
Type Description
Void

setSql(String)

Sets the query for the instance. This method is not available in CRM Online.

Declaration
Void setSql(String sqlStatement)
Parameters
Type Name Description
String sqlStatement

The SQL query to execute for the instance.

Returns
Type Description
Void

setStringMatrix()

Use the given StringMatrix entry as query (instead of SQL string).

Declaration
Void setStringMatrix(StringMatrix sm)
Parameters
Type Name Description
StringMatrix sm

The StringMatrix entry to use.

Returns
Type Description
Void
In This Article
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top