using SysGlobalcache in a custom class - fails when run in batch


   Below is the original line in an existing custom class that is using 

SysGlobalCache globalCache;

boolean isProforma;

isProforma = globalCache.get(curUserId(), 'IsProforma'); // This line returns anytype object and it this case it is returning false when run on the client side as expected. 

When running in a batch it is failing on the server and throwing the error. So, I change the line to below to add any2enum conversion run time funcation as below to convert the anytype to boolean.
isProforma = any2enum(globalCache.get(userId, 'IsProforma'));

But it still fails and throwing an error something like below

Microsoft.Dynamics.Ax.Xpp.ErrorException: Exception of type 'Microsoft.Dynamics.Ax.Xpp.ErrorException' was thrown.

at Microsoft.Dynamics.Ax.MSIL.Interop.throwException(Int32 ExceptionValue)

at Microsoft.Dynamics.Ax.MSIL.Interop.ThrowCQLError(IL_CQL_ERR cqlErr)

at Microsoft.Dynamics.Ax.Xpp.CastHelper.ToBoolean(Object _value)


Is there a way to change the line of code to use a different conversion runtime function in the line of code isProforma = any2enum(globalCache.get(userId, 'IsProforma')); to avoid the error?