--- tags: - data collection alias: tutorial-datacollection-edc-parameters-calculated-errorsandexpressionvalidation timetoread: true description: "The documentation details expression validation rules for CM MES, covering syntax, data types, and potential errors during data collection creation" --- # Errors and Expression Validation To correctly evaluate an expression, you must perform validations as described below. ## Syntax The syntax of the expression is validated by the Code Editor element of CM MES. However, an additional validation is performed when the **Data Collection** entity, version or revision is created. If the expression has an invalid syntax, the following error is displayed in the wizard: `The syntax for the expression provided on parameter {0} is invalid.` The `{0}` is the name of the parameter with the invalid syntax. This error has the internal code `Bo61873`. If you try to import a **Data Collection** that contains a parameter with an invalid expression using Master Data, the Master Data load operation will fail and the following error is displayed: `The syntax for the expression provided on the parameter {0} of Data Collection {1} is invalid.` The `{0}` is the name of the parameter and the `{1}` is the name of the **Data Collection**. This error has the internal code `Bo61882`. If the expression is left empty, the following error is displayed instead: `Missing mandatory field Expression.` This error has the internal code `Val50074`. ## Data Types Just like the parameters of calculation type Rule, the resulting value for an expression is validated against the data type of the parameter. If the resulting value of an expression cannot be converted to the data type of the parameter, the following message is displayed: `Value 'Bad Text' is invalid for Property CP_79459_Dec03. It must be Decimal.` ## Business Related At two distinct moments during CM MES operations, business-related validations are also performed (see below). These occur when a **Data Collection** is being created or updated, and when the **Data Collection** is being performed. ### Create Data Collection In addition to the error `Bo61873`: `The syntax for the expression provided on parameter {0} is invalid.`, referenced on the Syntax section, the system also validates if an expression references a parameter in the current **Data Collection** that has a higher order, and is of calculation type Rule or Expression. This is done because these parameters are evaluated according to their order, so the system must protect against a calculated parameter referencing another that was not yet evaluated. If this validation fails, the following message is displayed: `The expression provided on parameter {0} references parameter {1}, which has calculation type Rule or Expression and a higher order.` The `{0}` is the name of the parameter with the error, and the `{1}` is the name of the parameter it references. This error has the internal code `Bo61874`. Although the user interface does not allow for defining a Limit Checking Mode or Calculation Grouping Mode for Expression parameters, the system also validates if the expected values are present when creating a **Data Collection**. Like other CM MES validations of this nature, an error with the internal code `Val50053` is thrown; its message will be similar to this: `It is not possible to define the property CalculationGroupingMode with value Parameter for type Data Collection Parameter with the property Calculation having value Expression.` ### Perform Data Collection These validations are mainly related to external **Data Collections**. If an expression references an external **Data Collection** (using the `DC("")` function), you must provide a **Material** or **Resource** as context when performing the **Data Collection**. If you fail to do so, the following error is displayed when trying to perform the Data **Collection**: `A Resource or Material context must be provided for evaluation of Expression parameter.` This error has the internal code `Bo61869`. Likewise, if an expression references the attributes of a **Material** or **Resource**, but no context was provided, the following error is displayed: `A {0} context must be provided for evaluation of Expression parameter.` The `{0}` is either a **Material** or **Resource**, depending on whether the expression references **Material** or **Resource** attributes. This error has the internal code `Bo61884`. If you provide a **Material** or **Resource**, but the **Data Collection** does not exist, the following error is displayed: `The Data Collection {0} referenced by the expression of the parameter {1} was not found.` The `{0}` is the name of the referenced **Data Collection** that does not exist, and the `{1}` is the name of the parameter where the non-existent **Data Collection** is referenced. This error has the internal code `Bo61871`. If you provide a context and the referenced **Data Collections** exist, but the provided entity does not have a **Data Collection Instance** in the referenced **Data Collection**, the following error is displayed: `The Data Collection {0} does not contain any Data Collection Instance for the {1} {2}.` The `{0}` represents the name of the referenced **Data Collection**, the `{1}` is either a **Material** or **Resource**, and the `{2}` is the name of the entity. This error has the internal code `Bo61870`. ## Generic Errors If the evaluation of an expression fails for any other reason, the system creates an error message that states the parameter that failed as well as the JSONata evaluator error message. In that case, the following error is displayed: `The evaluation of the parameter {0} was not successful. JSONata error: {1}.` The `{0}` is the name of the parameter, and the `{1}` is the JSONata error message. This error has the internal code `Bo61889`.