Using the SourceExpr and DestExpr Properties
In the last section, we’ve discussed how to add table instances to a mapping. In this section, we’ll look at how to access the data of fields in a table. And how to use constant values and filters.
The module allows you to read data from fields from tables, whenever there is a SourceExpr (source expression) property. The SourceExpr can also be used to specify constant values or to call functions. You will find this property on the data lines of mapping of format type NAV and on the data lines of export mappings. But this property is also available for parameters of custom function and to extend error messages. There are more options, which we will discuss a little bit later in this section.
To write data to table fields there is another property called DestExpr (destination expression). This property also allows you to check data against a specified filter, instead of storing it. We will go into the details in a moment. It is important to know that you can write data to any field of a table instance, even if the table Mode is set to Read. Writing to a table in read mode will call the validation logic of NAV, but we don’t modify the record. On our buffer tables you can use this to store a value for a certain time in the mapping. On other tables it will depend on the validation logic, whether it is safe to use a table in read mode to temporarily store data.
The SourceExpr Property
The source type specifies what kind of data you want to read. The allowed values are:
A constant value that is entered in the mapping.
A field from a table instance, that is one of the parent mapping lines of this mapping line. In case you want to read a sum field you have to be outside the table instance, but below it.
You want to read data from either a build-in or a custom function.
This property was added in Anveo EDI Connect 4.00.
This property is only available if the SrcType is set to Const. This property specifies the data type of the constant value. You have to select the data type, to prevent errors due to different locales used during setup and runtime. In older version you had to ensure that the locale during setup was the same than during runtime to prevent, for example, numbers to be interpreted differently.
You can choose from the following data types:
A constant text value.
A text that can contain special characters, like a carriage return (<CR>). There is a list of all supported special characters.
A boolean value, like True or False.
An option value. You should use the integer value of the option in the database.
An integer value (32 bit).
A decimal value.
A large integer value (64 bit).
The value contains a duration.
The value is a Dynamics code value (uppercase only, does not allow all characters).
Represents a date value.
Represents a time value.
Represents a combined date and time value.
A date formula.
A global unique ID (GUID).
This property is only available if the SrcType is set to Const. Represents the constant value that you want to use.
This property is only available if the SrcType is set to Function. You can use the AssistEdit to specify the object and function. If the function required parameters, these will be SourceExpr as well, but do not support nesting of functions.
This property is only available if the SrcType is set to Field. Select the table instance to read the data from. The table need to be one of the parents of the current mapping line, to read the data of one record. If you want to read sum fields, you have to be under the table instance, but not a child of it.
This property is only available if the SrcType is set to Field. Selects the column / field you want to read from.
You can specify a value translation, to change the selected value to a different target value. There is a section on how-to setup value translations.
The code of the value translation that should be used.
What should happen, if the value is not found in the value translation.
The module does nothing if the translation is missing. It uses the original value without translation.
Output an empty value.
Add a information log entry and use the original value.
Add a warning log entry and use the original value.
Break the mapping immediately and log an error.
Create an error log entry and do not successfully finish the mapping, but continue with the processing to find other errors as well.
This property is hidden by default. You can specify a list of allowed values and create errors, iof you try to export another value.
The list of allowed values. You can either use the AssistEdit or enter the terms comma separated.
What should happen, if the source value is not in the list of allowed value.
Do not use the advanced validation and ignore any values in the list.
Create a information log entry.
Create a warning log entry.
Break the mapping immediately with an error message.
Return an error on mapping execution, but continue to process the mapping, to find other errors as well.
The DestExpr Property
Select the target for a value. The following values are valid:
Empty means that the value is ignored. You can use this to skip fields on imports or, for example, to ignore a function return value.
The value should be checked against a Dynamics filter. If the filter does not match the value is not accepted. Depending on the converter this will result in an error message or in skipping a section of the mapping. You’ll learn more on the use of filters for specific converter on the documentation of each converter.
The value should be written to a field of a table instance in this mapping.
This property is only available if the DestType is set to Filter. The Dynamics filter the value is checked against. The value will be interpreted as a text value for applying the filter. A typical example would be “BY|IV”, to allow the values “BY” and “IV”.
This property is only available if the DestType is set to Field. Selects the table instance the value should be written to. The table instance has to be one of the parents of the current mapping line.
This property is only available if the DestType is set to Field. The field name/column name of the target field on the table.
This property is only available if the DestType is set to Field. This property is only available as an advanced property. Setting this property to False will skip the Microsoft Dynamics NAV 2018 validation trigger for that field.
Be very cautious when using False. You should only deactivate the validation after consulting a programmer. You should not deactivate it on any of the standard Dynamics tables, except you really know what you are doing. You can make Microsoft Dynamics NAV 2018 unusable, by skipping validation code.
This property is only available if the DestType is set to Field and you’re using the NAV converter. You can find more information on the converter page.