CLRInterop::getObjectForAnyType Method [AX 2012]
Converts a value of the X++ anytype data type to a value of the CLRObject data type.
client server public static CLRObject getObjectForAnyType(anytype anyType)
Run On
CalledParameters
- anyType
- Type: anytype
The X++ value to convert to a value of the CLRObject data type.
If an attacker can control input to the getObjectForAnyType 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 the CLRObject type, an exception of the Exception::CLRError type is thrown.
The following example converts a string value to a CLR string object.
static void Job3(Args _args)
{
CLRObject clrObj;
InteropPermission perm;
System.String s;
perm = new InteropPermission(InteropKind::ClrInterop);
if (perm == null)
{
return;
}
perm.assert();
s = CLRInterop::getObjectForAnyType("Calculate total");
CodeAccessPermission::revertAssert();
}
Show: