Teach Me NAV
A site to support our book 'Implementing Microsoft Dynamics NAV 2009'.
Service Tier and Classic Client Monstrous Nightmare with FieldRef
Dave's Blog

My Novel on Kindle

 

Syndication

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);

MESSAGE('ISSERVICETIER=%1\Document Type=%2',ISSERVICETIER,lFieldRef.VALUE);

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

image

Then the RoleTailored client…

image

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.


Posted 08-12-2011 9:49 p.m. by David Roys

Comments

Ian wrote re: Service Tier and Classic Client Monstrous Nightmare with FieldRef
on 08-15-2011 9:10 a.m.

How did you resolve it Dave?

David Roys wrote re: Service Tier and Classic Client Monstrous Nightmare with FieldRef
on 08-15-2011 9:26 a.m.

Hi Ian,

the solution was easy - we only wanted the string value. The old code tried to evaluate the value into an integer field and then it used that for something. This is why it was failing. We were simply logging the value somewhere and not trying to use it. Our new code simply said if we're on the servicetier, use the value as is without trying to evaluate into an integer. It stopped the error but changed the logging so it stored the text instead of the number.

If you need to find the number from the text, I believe there's an example of how to do this in the DataMigration codeunit as it needs to do a similar thing.

Cheers,

Dave.

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
Powered by Community Server (Non-Commercial Edition), by Telligent Systems