CLRInterop::getAnyTypeForObject Method [AX 2012]
Converts a common language runtime (CLR) object to a value of the X++ anytype data type.
client server public static anytype getAnyTypeForObject(CLRObject clrObject)
Run On
CalledParameters
- clrObject
- Type: CLRObject Class
The CLR object to convert to an X++ data type.
If an attacker can control input to the getAnyTypeForObject method, a security risk exists. Therefore, this method runs under Code Access Security. Calls to this method on the server require permission. Make sure that the user has development privileges by setting the security key to SysDevelopment on the control that calls this method.
If the argument cannot be converted to an X++ data type, an exception of the Exception::ClrError type is thrown.
The following example sets the value of a CLR string to an X++ str data type.
{
CLRObject clrObj;
InteropPermission perm;
System.String clrStr = "Calculate total";
str s;
perm = new InteropPermission(InteropKind::ClrInterop);
if (perm == null)
{
return;
}
perm.assert();
s = ClrInterop::getAnyTypeForObject(clrStr);
CodeAccessPermission::revertAssert();
}
Show: