RecordRef filtering with ML option value

If you every been collecting record changes or dynamically setting filters in NAV, you properly will know the concept of RecordRef and FieldRef. It is very powerful and very interesting to use.

I have used the concept to create a functionality where we can send customer records to a web service dynamically.
To make it flexible I have added the ability to set a filter on the customer table. In my example I will only send customers that are not Blocked for All.
Every evening the job queue sends out all the customers as you have configured.

As long as you configure everything in English, the system will run perfect. But what if your administrator has configured everything with the NAV Client loaded in Dutch?

Bam Error

The reason for this, is because the filter value is saved in the database with a simple FORMAT(Filter). Wrong choice as you can see J. The job queue is running by a NAS in English and doesn’t recognize the Dutch option value.

So my code must be changed to make it run in a multi-language environment.
To achieve this I changed my code like this for single value filters:

As you can see I used a default code unit 5302 “Outlook Synch. Type Conv”. In this code unit there is a function called “TextToOptionValue” that converts an option value to an integer.

For complex filters I have used another default function called “EvaluateFilterOptionField”.
Which converts any option value within your complex filter.

After implementing all of this my filter value will look like this.

The system will now use the integer value instead of the text value. So my filter is multilingual and everything will run smoothly.
To make this solution complete you must implement the Boolean conversion too. By simple converting the value like this.

Leave a Reply

Your email address will not be published. Required fields are marked *