Service Tier and Classic Client Monstrous Nightmare with FieldRef

Monstrous Nightmare

I came across an error today that was a monstrous nightmare to track down. First of all, it worked in the Classic client but not in the RoleTailored client. Sigh. Don’t you just hate that? It means going through the pain of debugging the RoleTailored client.

The error was caused because the FieldRef.Value function for a FieldRef that points to an Option type field returns different values in the Classic client and RoleTailored client.

If you want proof, try running this Codeunit in both the RTC and Classic.

// ServiceTier returns different values for FieldRef.Value for Option
// fields compared to Classic client.

lRecordRef.OPEN(DATABASE::"Sales Header");

lFieldRef := lRecordRef.FIELD(1);


You’ll see the following results. Classic client first…


Then the RoleTailored client…


You see that? One returns the string value and the other returns the numeric value for the option string.

The error we were getting was because the field was being used as an Integer which was throwing a run time error whenever it hit that particular bit of code but only when using the RTC.

Most of the time in finding this error was in tracking down the line of code that was causing the error to be thrown. I was reading the Statement of Direction for NAV the other day and noticed it suggests we’ll be getting an easy-to-use debugger for the RTC in a future version – I can’t wait! Let’s hope in the future I can say “break on error” and just run my RoleTailored client and find out what the issue is straight away.

Comment List