Export (0) Print
Expand All

DictClass.callObject Method [AX 2012]

Calls a method on an object.

public anytype callObject(
    str methodName, 
    Object Called, 
     )

Run On

Called

Parameters

methodName
Type: str
A string data type that indicates the name of the method to call.
Called
Type: Object Class
An instance of the object class.
Type: [T:]

Return Value

Type: anytype
An anytype data type value that is returned by the specified method.

You must create an instance of the DictClass object by using a class that contains the method that you pass to the callObject method. If an attacker can control the input to the callObject method, a security risk exists. Therefore, this method runs under code access security. Calls to this method on the server require permission from the InteropPermission class. Make sure that the user has development rights by setting the security key to SysDevelopment on the control that calls this method.

This example calls the toString instance method in the Info class, for which the global instance of this class is named infolog, and then prints the value that is returned from the call.

static void Job_Example_DictClass_CallObject(Args _args) 
{ 
    DictClass dictClass; 
    anytype   retVal; 
    str      resultOutput; 
    ExecutePermission perm; 
     
    perm = new ExecutePermission(); 
  
    // Grants permission to execute the DictClass.callObject method. 
    // DictClass.callObject runs under code access security. 
    perm.assert(); 
  
    dictClass = new DictClass(classidget(infolog)); 
    if (dictClass != null) 
    { 
        retVal       = dictClass.callObject("toString", infolog); 
        resultOutput = strfmt("Return value is %1", retVal); 
        print resultOutput; 
        pause; 
    } 
     
    // Closes the code access permission scope. 
    CodeAccessPermission::revertAssert(); 
}

Community Additions

ADD
Show:
© 2014 Microsoft