Tax Engine - Script activity

Use script activities to calculate intermediate values, apply conditions, and add validations within a tax use case. Open a use case and choose Computation Script to edit its calculation script.

String and text activities

  • Concatenate: Concatenates list values and outputs to a variable.

  • String Expression: It's used to compose string. Names that are enclosed within curly braces are treated as tokens. Values can be assigned to tokens using lookups, whereas on the Value tab, source of that token can be defined.

  • Length of String: Calculates the length of the string and assigns it to the output variable.

    TypeDescription
    Output VariableSpecifies the name of variable in which value of the length is stored.
    StringSpecifies the string for which length is to be calculated, hard coded text or/and expression can be entered.
  • Convert Case of String: Converts the case of the string and assigns to the output variable.

    TypeDescription
    Output VariableSpecifies the name of variable in which value of converted case is stored.
    StringSpecifies the string for which case is converted, hard coded text or/and expression can be entered.
    Convert to CaseConverts case of the string, it can be either Upper Case or Lower Case.
  • Find Substring in String: Finds the substring in string and assigns the position of the substring to output variable.

    TypeDescription
    Output VariableStores the position where the substring starts. The result is 0 if the substring isn't found.
    StringThis is the string for which value of substring is searched, hard coded text or/and expression can be entered.
    SubstringSpecifies the string or expression, which needs to be identified from String value.
  • Replace Substring in String: Replace substring in a string with a new string and assigns to output variable.

    TypeDescription
    Output VariableSpecifies the name of variable in which the value of Replaced String is stored.
    Sub StringThis is the string content, which is replaced from 'In String', hard coded text or/and expression can be entered.
    With StringSpecifies the replacement text. It replaces each occurrence of Sub String in In String.
    In StringThis is the string on which replacement of character happens.
  • Extract Substring: Extracts substring of a length from a string from start/ end and assigns to output variable.

    TypeDescription
    Output VariableSpecifies the name of variable in which value of Extracted Sub String is stored.
    StringThis is the string for which value of Substring is extracted, hard coded text or/and expression can be entered.
    FromStarting point of extraction, it can be either start or end.
    LengthNumber of characters to extract.
  • Extract Substring from Index of String: Extracts substring of a length from a string with an index and assigns to output variable.

    TypeDescription
    Output VariableSpecifies the variable name in which value of Extracted Sub String is stored.
    In StringThis is the string for which value of Substring is extracted, hard coded text or/and expression can be entered.
    From IndexStarting point of extraction as Index.
    LengthNumber of characters to extract. A value of 0 extracts the remaining text from From Index.

Number activities

  • Number Calculation: Calculates the number based on values and the operator. It's assigned to output variable.

    TypeDescription
    Output VariableSpecifies the variable name in which value of Calculated Number is stored.
    ValueThis is the Left-Hand Side (LHS) of the Number Calculation.
    OperatorOperator to be used for calculation, it can be Addition, Subtraction, Division, Multiplication.
    Value 2This is the Right-Hand Side (RHS) of the Number Calculation.
  • Numeric Expression: Numeric Expression is to evaluate expression into number and assign it to output variable. Text token is extracted and replaced with values from Lookups, whereas on the value tab source of that token can be defined.

  • Round Number: Round Number is used to round decimal places to a precision and direction could be nearest, up or down.

    TypeDescription
    Output VariableSpecifies the variable name in which value of Rounded Number is stored.
    NumberValue that is rounded.
    PrecisionRounding precision.
    DirectionDirection of rounding, it can be Nearest, Up, or Down.

Date activities

  • Date Calculation: ‘Date Calculation’ is used to manipulate dates by adding or subtracting number of days / months / years and it's assigned to output variable.

    TypeDescription
    Output VariableSpecifies the name of variable in which value of ‘Calculated Date’ is stored.
    DateThis is the date on which calculation is done.
    OperatorThis is the operator that is applied on ‘Date for calculation’.
    NumberThis is the number that is added or subtracted to date.
    PeriodThis is the type that is added or subtracted to date as Number. It can be Days, Week, Months, Year.
  • Extract Date Part: ‘Extract Date Part’ is used to extract day/month/year from a date and assign it to output variable.

    TypeDescription
    Output VariableSpecifies the variable name in which value of Extracted Date is stored.
    DateThis is the Date on which extraction is done.
    PartType of extraction, it can be Year, Month, Day.
  • Find Interval between Dates: Subtracts From Date from To Date and assigns the number of days to the output variable.

    TypeDescription
    Output VariableSpecifies the variable name in which value of Interval is stored.
    From DateThis is starting date of date range.
    To DateThis is ending date of date range.
  • Extract Date Time Part: Extracts the date or time from a 'date time value'.

    TypeDescription
    Output VariableSpecifies the name of variable in which value of date or time is stored.
    Date TimeThis is the date time value from which extraction is done.
    PartPart that is extracted, it can be either date or time.
  • Date to Date Time: Converts a ‘Date’ value to ‘Date Time’

    TypeDescription
    Output VariableSpecifies the name of variable in which value of ‘date time’ is stored.
    DateThis is the date value, which is part of 'date time'.
    TimeThis is the time value, which is part of ‘date time’.

Conditional activities

  • If Statement: Activities within the "If" statement is executed when the defined conditions are evaluated to be true. If the conditions are evaluated to false, activities in the “Else” branch are executed. Conditions can be specified in “Else” branch. There can be more than one else branch for an “If Statement”.

Loop activities

  • Loop n Times: Executes activities in the loop block for n number of times. "N" can be a constant value, or it can be a variable.

  • Loop with Condition: Executes activities in the loop block until condition is evaluated to be false.

  • Loop through Records: Loop through all records and execute activities in the Loop block.

    TypeDescription
    Table NameName of table whose records need to be iterated.
    SortingSorting order of the records.
    OrderAscending or Descending.
    DistinctSkips subsequent records with the same values in the configured sorting fields. Configure Sorting to define which values identify a distinct group.
    Table FiltersFilters to be applied on the table records.
    Index VariableLoop index starts from 1.
    Count VariableStores the count of records after applying filters. This field isn't available when Distinct is turned on.
    Set VariablesMaps fields from the current record to script variables for each iteration.
  • Exit Loop: Ends the loop and continues with the activities after the loop block.

  • Skip Next Activities: Skips next activities in the loop block and continues execution of the next iteration.

Variable and message activities

  • Set Variable: To assign Variable value.

    TypeDescription
    Output VariableThe variable, which is assigned with value.
    ValueThe value of variable, this can be constant or lookup.
  • Alert Message: Displays a message during script execution when a user interface is available. This activity can help with debugging. Turn on Throw Error to raise an error and stop execution instead.

    TypeDescription
    MessageMessage that is to be displayed.
    Throw ErrorCheck this flag to throw error message.

Tax Engine Design Consideration

Find free e-learning modules for Business Central here