Calculated Fields Functions

In the workflow manager its possible to use a action calculated field.

This is a SuiteCrm functionality, which is documented here: https://docs.suitecrm.com/user/advanced-modules/workflow-calculated-fields/

The DataEngine adds the following functions:

GetValueForKey

Signature {GetValueForKey(parameter1;parameter2)}

Parameters

parameter1: A base64 encoded serialized php array

parameter2: The key to fetch. Use . to access nested keys

Description

Get a value from a serialized php array by key.

Returns

The value for the key or null if the key does not exist.

Example call

{GetValueForKey({P0};abc)} – Get the value for the key abc from the serialized php array in parameter 0.

{GetValueForKey({P0};abc.def)} – Get the value for the key def in abc from the serialized php array in parameter 0.

Base64Encode

Signature {Base64Encode(parameter1)}

Parameters

parameter1: The string to encode

Description

Encode a string to base64.

Returns

The base64 encoded string.

Example call

{Base64Encode(abc)} – Encode the string abc to base64.

Base64Decode

Signature {Base64Decode(parameter1)}

Parameters

parameter1: The base64 encoded string to decode

Description

Decode a base64 encoded string.

Returns

The decoded string.

Example call

{Base64Decode("YWJj")} – Decode the base64 encoded string YWJj to abc.

CreateJSON

Signature {CreateJSON(parameter1;parameter2;parameter3;...)}

Parameters

parameterX: The key and value to add to the json object. The key and value are seperated by a .

Description

Create a json object from the given parameters.

Returns

The json object string.

Example call

{CreateJSON(abc.def;ghi.jkl)} – Create a json object {"abc":"def","ghi":"jkl"}.

{CreateJSON(name.{P0};value.{P1})} – Create a json object {"name":<Value of P0>,"value":<Value of P1>}.

JsonExtract

Signature {JsonExtract(parameter1;parameter2;parameter3)}

Parameters

parameter1: The json object string

parameter2: The key to fetch

parameter3: The default value if the key does not exist

Description

Get a value from a json object by key.

Returns

The value for the key or the default value if the key does not exist.

Example call

{JsonExtract({P0};abc;default)} – Get the value for the key abc from the json object from parameter 0. For {"abc":"def","ghi":"jkl"} would return def

{JsonExtract({P0};xyz;default)} – Get the value for the key xyz from the json object from parameter 0. For {"abc":"def","ghi":"jkl"} would return default.

JsonExplode

Signature {JsonExplode(parameter1;parameter2;parameter3)}

Parameters

parameter1: A string value seperated by the parameter 2

parameter2: The separator

parameter3: Default value. Caution this returns the value directly not an json array!

Description

Explode a string value to an json array.

Returns

The json array string.

Example call

{JsonExplode(abc;,;ghi)} – Explode the string abc to an json array ["abc"].

{JsonExplode(abc,def;,;ghi)} – Explode the string abc,def to an json array ["abc","def"].

{JsonExplode(;,;ghi)} – Explode the string “ to ghi as the value is empty.

{JsonExplode({P0},/n;ghi)} – Explode the string from parameter 0 by new line to an json array. For the value

abc
def
ghi

the result would be ["abc","def","ghi"].

JsonImplode

Signature {JsonImplode(parameter1;parameter2;parameter3)}

Parameters

parameter1: A json array string

parameter2: The separator

parameter3: Default value. This is only used if the json is invalid!

Description

Implode a json array to a string value.

Returns

The string value.

Example call

{JsonImplode({P0};,;)} – Implode the json array from parameter 0 to a string value. For ["abc","def","ghi"] the result would be abc,def,ghi.

{JsonImplode({P0};,;invalid_json)} – If parameter 0 is not a valid json the default value invalid_json is returned.

Count

Signature {count({BeanID};{RelatedModule};{Field};{DateField};{Operator};{Date})}

Parameters

BeanID: ID of the Bean from which to start.

RelatedModule: Name of the relationship as defined in the Studio. Multiple relationships can be linked using :: (From Contact to Company, From Company to Invoice). It can be empty to count all entries in the module table.

Field: Name of the field to be counted, e.g., id. If a field other than “id” is specified here, it is checked that this field is not empty. This allows for a different result than counting over “id”. The field must come from the last mentioned “RelatedModule.”

DateField: (Optional) A date field from the last mentioned “RelatedModule” used for date filtering.

Operator: (Optional) An operator for date filtering. Possible operators are lt, lte, gt, gte, eq, neq.

Date: (Optional) A date in the format Y-m-d H:i:s for date filtering.

Description

Counts the entries related to the specified Bean. It is possible to filter the count based on a date field in the associated module, such as for “Only invoices from the last 2 years.” If a field is specified, it must not be empty.

Return

Number of results.

Example Calls

{count({P0};;id)} – Counts all entries in the current module

{count({P0};core_accounts_core_contracts;contract_volume)} – Counts the contracts of the current account with non-empty volume

{count({P0};core_accounts_core_contracts;contract_volume;last_invoice;gt;{subtractYears(Y-m-d;{now(Y-m-d)};2)})} – Counts the contracts of the current account with non-empty volume that have received an invoice in the last two years.

{count({P0};core_accounts_core_contacts::core_accounts_core_contracts;contract_volume)} – Counts the contracts of the account of the current contact with non-empty volume.

Sum

Signature {sum({BeanID};{RelatedModule};{Field};{DateField};{Operator};{Date})}

Parameters

BeanID: ID of the Bean from which to start.

RelatedModule: Name of the relationship as defined in the Studio. Multiple relationships can be linked using :: (From Contact to Company, From Company to Invoice). It can be empty to sum all entries in the module table.

Field: Name of the field to be summed from the last mentioned “RelatedModule.”

DateField: (Optional) A date field from the last mentioned “RelatedModule” used for date filtering.

Operator: (Optional) An operator for date filtering. Possible operators are lt, lte, gt, gte, eq, neq.

Date: (Optional) A date in the format Y-m-d H:i:s for date filtering.

Description

Sums the values of entries related to the specified Bean. It is possible to filter the summation based on a date field in the associated module, such as for “Only invoices from the last 2 years.”

Return

Sum

Example Calls

{sum({P0};;amount)} – Sums the amounts across all entries in the current module

{sum({P0};core_accounts_core_contracts;contract_volume)} – Sums the contract volume of the contracts of the current account

{sum({P0};core_accounts_core_contracts;contract_volume;last_invoice;gt;{subtractYears(Y-m-d;{now(Y-m-d)};2)})} – Sums the contract volume of the contracts of the current account that have received an invoice in the last two years.

{sum({P0};core_accounts_core_contacts::core_accounts_core_contracts;contract_volume)} – Sums the contract volume of the contracts of the account of the current contact

Marini Systems GmbH | Contact SupportMarini Website | Privacy Statement | Legal