Learn about creating formula expressions using Safety-specific functions.

About Formula Expressions

Safety Vaults include several formula expressions that you can use when configuring certain features, including:

For more information about using formulas in Vault, see:

Safety Functions

The following functions are specific to Safety. You can use these functions to define expressions that return true or false:

VS_ANYOF

VS_ANYOF(array_expression, LAMBDA(array_element_alias, boolean_expression))

This function returns true or false depending on whether or not the boolean_expression is true for any of the array elements (array_element_alias) in the array_expression.

Example

The following example returns true if any of the Case Adverse Events related to this Case have a Days Hospitalized value of two (2) or more:

VS_ANYOF(case_version__v.case_adverse_events_case_version__vr.days_hospitalized__v, LAMBDA (e,e>2))

VS_CONTAINS

VS_CONTAINS(string array, string)

This function returns true or false depending on whether or not string is present inside string array.

Example

The following example returns true:

VS_CONTAINS(["one", "two", "three"], "two")

VS_HASONE

VS_HASONE(objectreference)

This function returns true if there is exactly one (1) record of the specified object for the Case.

Example

The following example returns true if the Case Product has one (1) Case Product Indication:

VS_HASONE(case_version__v.case_products_case_version__vr.case_product_indications__vr)

VS_HASMANY

VS_HASMANY(objectreference)

This function returns true if there are multiple records of the specified object for the Case.

Example

The following example returns true if the Case Product has multiple Case Product Indications:

VS_HASMANY(case_version__v.case_products_case_version__vr.case_product_indications__vr)

VS_LET

VS_LET(var, path_to_validating_records, expression)

This function returns the result of a validation performed on object records. This function includes the following inputs:

  • var: Specifies an alias to the records found at the resolved path_to_validating_records. You can use this alias in place of the path in your expression to make it easier to read.
  • path_to_validating_records: Specifies the object path Vault validates, beginning from the top-level object (for example, case_version__v, transmission__v, localized_case__v) or the specified var, with each following node in the path separated by a period (.). The path navigates through the objects using the appropriate object field relationship names.
  • expression: Specifies the expression Vault will evaluate on the validating records, returning as true or false.

Example

The following example validates that when the MPID field of a Case Product contains a value, the MPID Version must also contain a value:

VS_LET(cp, case_version__v.case_products_case_version__vr, IF(NOT(ISBLANK(cp.mpid__v)),NOT(ISBLANK(cp.mpid_version__v)),TRUE))

VS_MATCHES

VS_MATCHES(string, string)

This function returns true or false depending on whether or not string matches the regular expression (regex) in string.

Example

The following example returns true:

VS_MATCHES("veeva", "^veeva.*$")