Full width home advertisement

Post Page Advertisement [Top]


Delegate Result with EventHandlerResult 

In this demo we will show to get Result from delegate subscribe events.


In normal routine mostly Ax Technical use subscribe event of delegates and perform the required task and get required result. Following are the few steps through them you can achieve the same.

Lets begin.

Step-1 Create a class with name of SLD_DemoSample
Step-2 Add two method Main and run in this class like below screenshot

Reference screenshot

Step-3 Create a delegate in the class with two parameters like below

delegate void showMessage(Description _msg, EventHandlerResult result)  {    }

Reference screenshot

Step-4 Subscribe the event of newly created delegate and paste in the class 

Reference screenshot


  /// <summary>
    ///
    /// </summary>
    /// <param name="_msg"></param>
    /// <param name="result"></param>
    [SubscribesTo(classStr(SLD_DemoSample), delegateStr(SLD_DemoSample, showMessage))]
    public static void SLD_DemoSample_showMessage(Description _msg, EventHandlerResult result)
    {
        result.result(strFmt("Message received from run method is %1",_msg));
    }

Step-5 Use result object of  EventHandlerResult class (2nd parameter) to return the response to caller like result.result(strFmt("Message received from run method is %1",_msg));

Reference screenshot


Step-6 Now call the delegate from the method and pass the required parameter like below.

        EventHandlerResult result = new EventHandlerResult();
        Description message='Hello world this is an event handler';
         
         info('Before..');

         this.showMessage(Message,result);
        
         info(result.result());

         info('After...');

Reference screenshot


Please feel free to contact me if you are facing any issue during implementation of this blog.

Tidak ada komentar:

Posting Komentar

Bottom Ad [Post Page]