Check if a field is mapped in an AOT map
When you work with AOT maps, it might be that not all related tables have mappings to all fields of your map. This can lead to runtime errors unless you handle the missing mappings in your code.
For example your map might contain fields Field1, Field2, Field3 and Field4, but only the first three fields are mapped to Table1, and only the last three fields are mapped to Table2. If you now assign a Table1 buffer into your map variable, and try to reference Field4, the compiler accepts your code and you can build it succesfully. But when the user is running the application, she will get error "Error executing code: The field with ID '0' does not exist in table '[MyMap]'."
In order to handle this scenario, you can use the SysDictField class to see if the field is mapped for this table:
if (SysDictTable::isFieldMapped(tableStr(MyMap), tableId2Name(myMap.TableId), fieldStr(MyMap, Field4)))
{
// Handling for table buffer that have Field4 mapped
}
else
{
// Handling for table buffer that don't have Field4 mapped
}

Like
Report
*This post is locked for comments