Call any method of class in D365 FO x++

 public anytype callClassMethod(ClassId _classId, MethodName _methodName, boolean isInstanceMethod, Common _record)

{
     anytype returnObject;
     SysDictClass dictClass = new SysDictClass(_classId);

 

     if(isInstanceMethod)
     {
         returnObject = dictClass.callObject(_methodName, classFactory.createClass(_classId), _record.TableId, _record.RecId);
     }
     else
     {
         returnObject = dictClass.callStatic(_methodName, _record.TableId, _record.RecId);
     }

 

     return returnObject;
}


Example:

  public str getApproverNames(Common _record)
  {
      str name;

 

      name = this.callClassMethod(className2Id('DSSWorkflowUtil'), 'getApproverNames', true, _record);

 

      return name;
  }

Comments

Popular posts from this blog

step 20 Update script for service model: AOSService on machine: CR-VM-Test-1

How to Bypass Next in COC in D365 X++