Table of Contents

CAST

Specification Value
Name CAST
Description The CAST operator converts a parameter to a specified type.
It is commonly used by other operators to ensure parameter values are of the same type, particularly when the type one of these parameters is a custom ERP.net type (e.g., a specific enum).
Parameter 1 Name param
Parameter 1 Type any type
Parameter 2 Name type
Parameter 2 Type const - 'System.Int32', 'System.String', 'System.Decimal', 'System.Double' and all standard .Net types + custom ERP.net types (e.g., a specific enum)
Parameter 3 Name
Parameter 3 Type
Return value Returns the param converted to the type.


Tip: If you can change the type using the CAST operator, you should typically use the CONVERT operator instead—and vice versa.


Example:

Let's convert the value of the state of a sales order with the type 'enum' to an integer number.

Converting to an integer allows for comparison between the states (lower -> higher):

10: CAST ATTRIB: State  CONST: System.Int32      

OUTPUT:
If 'State = Released', the output will be '30'.

More examples: