web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Call my class when record inserted in the staging table

(0) ShareShare
ReportReport
Posted on by 2,985

Hi,

When I modify the name of the customer, the record should get inserted into the staging table. when the record gets inserted into the table my class should run. The responses from the class should get inserted against the same record.

I created a method in the custable to insert the record in the staging table.(record get inserted in the staging table). I called this method in the modified field.

I called the class run method after a super call in the table insert method, but the record not inserted.

Any idea,what's the best approach.

I have the same question (0)
  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Pravasti,

    Which version of AX are you working on?

  • Suggested answer
    Martin Dráb Profile Picture
    239,069 Most Valuable Professional on at

    Let me guess. Your class is calling a web service, but the call throws an exception, which rollbacks the transaction (therefore nothing gets stored).

    This design is wrong. Any problem with the web service prevents you saving changes in AX, and even if it worked, it would have negative impact on performance. It's because the saving, including all locks in database, would have to wait for the web service to complete (or time out).

    You simply shouldn't call the class from the same transaction. For example, use a batch running every minute. And don't forget to handle CLR exceptions.

  • Pravasti AK Profile Picture
    2,985 on at

    Hi Martin,

    So how to handle it in a better way.

  • Pravasti AK Profile Picture
    2,985 on at

    It's a real time call, how I can handle in a batch

  • Pravasti AK Profile Picture
    2,985 on at

    Ax2009

  • Martin Dráb Profile Picture
    239,069 Most Valuable Professional on at

    Wow, so I guessed everything right? I'm getting better. :-)

    Unfortunately I don't know what you mean when asking "how to handle it in a better way" and what problem you have with making the call in a batch. You'll have to start giving us more information, otherwise we can't help you.

  • Pravasti AK Profile Picture
    2,985 on at

    Yes you are right Martin .If I remove throw Exception :: clrerror in the try statement I can able to see the records inserted in the staging table.

    Point1: If I extend my class in a run base batch how the call will be synchronous.

    Point 2:when the record is inserted in the staging table how I can trigger my batch job to run.

    Point3:If I bypass the clrerror , then how I can handle the exceptions.

    Point4:I can able to talk with the client and get the responses back successfully by adding service reference in vs and copied the .dll in  the bin folder of client and server and invoking the reference from aot.- As you said earlier I have not used aif and iis , but it's a synchronous call how I can handle the exception.

    Documents are less to handle in ax2009.

  • Martin Dráb Profile Picture
    239,069 Most Valuable Professional on at

    Point 1: You can make synchronous calls from a batch job in the same way as from any other code. But if your idea is doing  a web service call from update() of CustTable, this idea is wrong, as I explained. You mustn't do it. If a batch doesn't work for you for some reason, please explain the business problem that's preventing this desing. Note that "I want it" isn't a business justification.

    Point 2: I said the batch would be running every minute, therefore you don't need any code in insert(). The batch would use a query to find all unprocessed records and handle them.

    Point 3: I don't know what you mean "bypassing an error" and what prevents you from handling exceptions in the way you want. You'll have to be more specific.

    Point 4: As I explained in one of your previous threads, you can use try/catch block to catch exceptions. It sounds like you have a problem with it, but you forgot to explain it, therefore I can't comment on it unless you do it.

  • Pravasti AK Profile Picture
    2,985 on at

    So what's your approach,

    if any update happen in the cust table it should process and should store the responses back that's where I included the concept I staging table.Client gave the URL and I consumed it.

    As you said the batch will take care of the unprocessed records how to achieve that, can you explain that a bit in detail.

  • Martin Dráb Profile Picture
    239,069 Most Valuable Professional on at

    It's pretty easy: your staging table will have a status field. For example, it may be enum with values like New, Processed and Failed. Your batch will use a query to process just records with Status = New, it'll process them and change the Status to either Processed or Failed.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 658

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 495 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 315 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans