Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Class extensions in D365

(0) ShareShare
ReportReport
Posted on by 501

Hi all,

I am working with class extensions. I have studies some very helpful articles about class extensions.

We can add new instance and static variables and methods in class extension. But is there any way to modify or override an existing method in the extension class ??
e.g. 

There is a class named DmfIntegrationBridge and it has a method named getJobStatus, so i want to override this method in a way that i want to return some extra information from this method. So is there any way to do this?

We are going to restoring below 

*This post is locked for comments

  • Ehtasham Rahman Profile Picture
    Ehtasham Rahman 670 on at
    RE: Class extensions in D365

    Hi Shahrukh,

    Can you please paste the snapshot of your code which you have written to append some information with member variable of getJobStatus method? Actually I am trying to do same work but I don't know how to get the member variable in postEventHandler and assign it new value.

  • geminikartik Profile Picture
    geminikartik 241 on at
    RE: Class extensions in D365

    HI Shahrukh ,

    Have you ever faced below error or system exception while running export Recurring data job from Ax . We are having this outbound integration and when 3rd party application is trying to download zip file from blob provider , they are getting 500 internal system error and even as part of manage messages , I am able to see only Processed message status but not downloaded.

    I checked back in event viewer and got below exception details .

    EventData>

      <Data Name="ComponentName">ActivityRuntime</Data>

      <Data Name="exceptionMessage">System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list. at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args) at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args) at System.String.Format(IFormatProvider provider, String format, Object[] args) at Microsoft.Dynamics.Platform.Integration.Connectors.Runtime.IntegrationActivityRuntimeCodeMarker.WriteUnhandledException(Exception exception, String message, Object[] args) at Dynamics.AX.Application.DMFIntegrationBridge.`Export(IntegrationBridgeContract bridgeContract) in xppSource://Source/ApplicationFoundation\AxClass_DMFIntegrationBridge.xpp:line 96 at Dynamics.AX.Application.DMFIntegrationBridge.DMFIntegrationBridgeCoCHelper.`Export(DMFIntegrationBridge instance, IntegrationBridgeContract arg0) at Dynamics.AX.Application.DMFIntegrationBridge.Export(IntegrationBridgeContract bridgeContract) at Microsoft.Dynamics.Platform.Integration.Connectors.Runtime.IntegrationActivityRuntime.<Export>d__23.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Dynamics.Platform.Integration.Connectors.Runtime.IntegrationActivityRuntime.<ExecuteIntegrationAsync>d__21.MoveNext()</Data>

      <Data Name="infoMessage">Unhandled exception processing 'Id = 5637146826, Name = Test Outbound, Direction = Outbound, Data project = Test outbound'.</Data>

      </EventData>

    Somewhere DMFIntegrationBridge class failing during export operation. Please suggest .

  • Shahrukh Profile Picture
    Shahrukh 501 on at
    RE: Class extensions in D365

    Thanks Martin and Andre,

    My case was related to Post-Event handler and it is resolved. :)

  • Martin Dráb Profile Picture
    Martin Dráb 230,445 Most Valuable Professional on at
    RE: Class extensions in D365

    You can apply techniques we already mentioned, such as a post-event handler.

  • Shahrukh Profile Picture
    Shahrukh 501 on at
    RE: Class extensions in D365

    This getJobStatus method is returning DataJobStatusDetail object. and this class contains a member variable named ExecutionLog, I need to append some information in this ExecutionLog, so that it will return detailed information.

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,445 Most Valuable Professional on at
    RE: Class extensions in D365

    You asked the same question below my blog post about class extensions, so let me copy my reply here too:

    If you want to override a method, create a new class extending the base class and override the method. Inheritance (parent / child relationship and overriding) isn’t related to extensions.

    If you want to run some extra code on the beginning or the end of the method, you can also use events. You don’t need class extensions for this either.

  • Verified answer
    André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,391 Super User 2024 Season 2 on at
    RE: Class extensions in D365

    Hi Shahrukh,

    It really depends on the details what you want to achieve. If you can use e.g. a post event handler and want to execute some additional tasks, then it is possible. You have to explain what exactly you mean with "return some extra information". Where and what for will this be used?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans