Detecting RunTime Enviroment in NAV
‘In the beginning’ life was easy. All C/AL-code was executed on the C/AL-client.
When the NAS came with Navision Financials 2.65, there was no command to determin if C/AL was executed on the NAS. On the other hand, could the NAS only be run in Application-mode, so logging was made to the console.
The command ‘GUIALLOWED’ was introduced with MBS Navision Attain 3.01.
Finaly we could execute code depending on current runtime engine.
With the new 3-tier setup introduced with NAV 2009 this was not enought anymore since code now could be executed on the servicetier.
Then command ‘ISSERVICETIER’ was introduced, to allow the programmer to do special code if the user was running RTC.
With NAV 2009 Microsoft also introduces native webservices.
What if a fileimport is exposed as a webservice method in NAV?
As a webservice cannot interact with the user, any fileimport must be done from a fileshare (\\TierServer\Imports\) accessable from the ServiceTier.
Since the webservice-call is executed on the ServiceTier, we could use the command ‘ISSERVICETIER’.
Great! but wait… What if the same fileimport is also run by a user on RTC?
The sollution is to combine the commands ‘GUIALLOWED’ and ‘ISSERVICETIER’ as in the example below.