Parse

Article • 02.08.2022 • 8 minute(s) to read

Parse

The Parse Activity creates Entity Variables from the content of CSV or JSON files stored on the Novunex platform.

The behavior of the Outcome of the Parse Activity depends on the parsing configuration:

  • In case a CSV file is parsed and Parse single line is set to Yes, two Outcomes with different names are required:
    • As long as there are lines to parse, the Parse Activity parses one line and then is left by the Outcome defined in Outcome if not finished
    • When the Instance returns to the Parse Activity, the next line is parsed
    • When there are no more lines to parse, the Parse Activity is left by the Outcome defined in Outcome if finished
  • In case a JSON file is parsed or Parse single line is set to No, the Activity can have an arbitrary amount of Outcomes, but all Outcomes must have the same name.

In any case, each Outcome name can be used multiple times, if it is desired to continue the process in parallel. When the Activity is finished, the script of the configured Outcome or Outcomes are evaluated and only Outcomes with a script evaluating to true are followed. If no Outcome script evaluates to true, the Instance will be ended by entering the closed-state.

Activity config

General
  • Name - Name of the Activity.
  • Version - Version of this Activity used in the Process. If a new version of this Activity is available and you want to use it, you have to manually update the version here. When a new Activity is added to the Process, automatically the latest version is placed.
  • Timeout in second - Once this time is elapsed, the Activity is closed and the Instance changes into the faulted-state. The default Timeout is two minutes. The timeout can be shortened and extended by entering a custom duration. If the Activity is left after a timeout, the first Outcome is followed. If multiple Outcomes have the same name as the first Outcome, all of them are followed. However, a continuation after a timeout does not effect the Outcome Scripts, meaning only Outcomes with Outcome Scripts evaluating to true are followed.
  • Hide in process graph - Controls if the Activity is hidden (Yes) or shown (No) in the Process Graph on the Execution Screen.
  • Continue on error - If this is set to Yes, the execution of the Instance continues even if the Activity failed. If set to No, the Instance fails when the Activity fails by entering the faulted-state. In the case of a continuation after an error, the first Outcome is followed. If multiple Outcomes have the same name as the first Outcome, all of them are followed. However, a continuation after an error does not effect the Outcome Scripts, meaning only Outcomes with Outcome Scripts evaluating to true are followed.
Parse

Parse Activity specific configurations

GENERAL

General interaction configuration, shared with most other Activities

  • Disable activity - Disables (Yes) or enables (No) the Activity. When disabled, the Activity is not executed and passed like a Connection by following the first Outcome. If multiple Outcomes have the same name as the first Outcome, all of them are followed. Disabling the Activity does not effect the Outcome Scripts, i.e., still only Outcomes with Outcome Scripts evaluating to true are followed.
  • Retry on error - If set to Yes, an automatic retry is executed up to ten times. If set to No, no retries are done. Retries are issued when the Activity failed so that the Instance would enter the faulted-state if the retry is disabled.
  • Additional text for task list - Description of this Activity shown to the Users in their task list. You can enter this text directly or use Process Context Expressions to compile it.
SETTINGS

Configure the parsing of CSV or JSON content

  • Type - Defines if CSV or JSON files are parsed. Depending on this selection, different configurations need to be done:
    • Csv - Parses a CSV file

      • Create entity - Controls if a new Entity Variable is created (Yes) or not (No). If no new Entity Variable is created, an existing Entity or Context Variable or a new Context Variable can be used.
      • File Id - File ID of the CSV file to parse. This is the Id of an Attribute with type File,
        e.g., #[MyVariable.MyFile.Id].
      • Attribute - column map - Maps the columns of the CSV file to Attributes of the output Variable. A new mapping is created by clicking on Add:
        • Key - Target of the mapping, i.e., Attribute of the Variable configured in Variable
        • Value - Source of the mapping, i.e., the name or the number of the column. The numbering of the columns starts with zero. The columns can only be addressed by name if Has header is set to Yes.
        • Each mapping can be removed by clicking on .
      • Additional Attributes - Sets Attributes in the newly created Variable configured in Variable that are not sourced from the parsed CSV file. A new mapping is created by clicking on Add:
        • Key - Name of the Attribute
        • Value - Value for the Attribute specified either directly or determined by a Process Control Expression.
        • Each mapping can be removed by clicking on .
      • Has header - Selects if the first row is the header (Yes) or there is no header (No). If set to Yes, the names of the columns in the first row can be used to address the columns in Attribute - column map.
      • Delimiter - Delimiter character used in the CSV file. Common delimiter characters are coma ,, semicolon ;, colon :, tab \t and space .
      • Ignore parsing errors - If set to No, a parsing error will cause the Instance to fail. If set to Yes, the parsing error will be ignored, i.e., no error is triggered and the line is ignored without creating or setting any Variables from it.
      • Replace characters (old character -> new character) - This configuration allows you to replace characters in all the parsed values. The replacement will be done after the parsing and in all parsed values. A new replacement can be defined by clicking Add:
        • Key - Character to be replaced
        • Value - Replacement character
        • Each replacement can be removed by clicking on .
      • Parse single line - Configures if the file will be parsed in one go (No) or if each line is parsed separately (Yes). If each line is parsed separately, the parsing result of each line is written into an Entity or Context Variable. After parsing a line, the Parse Activity is left and the Process must be designed to handle the parsed line and loop back to the same Parse Activity to parse the remaining lines. Therefore, the Parse Activity has to have two separate Outcomes to do the looping and leave the loop, once all lines are parsed:
        • Outcome if not finished - Name of the Outcome followed as long as there are new parsed lines from the CSV file delivered
        • Outcome if finished - Name of the Outcome followed once the parsing has finished and there is no line delivered from the CSV file anymore

      Setting Parse single line to No and therefore configuring that all lines in the CSV file are parsed at once, only works if Create entity is set to Yes. Then, one Entity Variable per parsed line is created and the Parse Activity is left via the Outcome named Default once all lines are parsed.

    • Json - Parses one or multiple elements from a JSON string

      • Create entity - Controls if a new Entity Variable is created (Yes) or not (No). If no new Entity Variable is created, an existing Entity or Context Variable or a new Context Variable can be used.
      • Json value - The JSON string to be parsed entered either directly or determined by a Process Control Expression.
      • Json array property - Name or JSON path to an array element inside the JSON value. If this is specified, only the elements withing the array are parsed. If no array should be parsed, this configuration needs to be left empty. The elements in the JSON path leading to the array have to be separated by a period, e.g., MyValue.MyArray.
      • Entity unique attribute name - This configuration is only needed, when an array is parsed and the array holds an elements representing a unique key. In that case, Entity unique attribute name specifies which element in the array holds the unique key. The Activity will make sure that only one element per value of the unique is created. If multiple entries with the same key exist, only the first one is parsed and the others are ignored.
      • Assign json result to entity attributes - Maps the parsed elements to Attributes of the output Variable. A new mapping is created by clicking on Add:
        • Key - Target of the mapping, i.e., Attribute of the Variable configured in Variable
        • Value - Source of the mapping, i.e., the name or path of the JSON element. If the name of a singe element is not enough and a JSON path is required, the elements in the path separated by a period, e.g., MyValue.SubValue.TargetValue.
      • Additional Attributes - Sets Attributes in the newly created Variable configured in Variable that are not sourced from the parsed JSON
        • Key - Name of the Attribute
        • Value - Value for the Attribute specified either directly or determined by a Process Control Expression.
        • Each mapping can be removed by clicking on .
  • Variable - Name of the target Entity or Context Variable holding the parsed data.