Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / Data Entity logs by er...
Finance forum
Answered

Data Entity logs by errors

Posted on by 35

Hi

We have a simple custom FO DataEntity.

A POST-request is sent from an external application to this entity.

If the sent record doesn't exist, then it will be inserted in the destination table and by overriding of one of entity methods one can automaticall create an entry in a  custom log table.

When after that the same request is sent, then there is an error (because the record already exists) and a new log entry will not be created, All the overriden entity mehtods will not be called.

Questions:

1. Is it possible to fill such a FO custom table  log?

2. What are there other (better) possibilities? 

Thank's in advance!

Pavel

Categories:
  • pavel.stikhin Profile Picture
    pavel.stikhin 35 on at
    RE: Data Entity logs by errors

    An approach with another SQL-connection (class userConnection) has now worked for me ...

  • pavel.stikhin Profile Picture
    pavel.stikhin 35 on at
    RE: Data Entity logs by errors

    ok, thank you for your feedbacks!

  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,148 on at
    RE: Data Entity logs by errors

    I'm not sure whether the logging is possible within D365 or not in this scenario. For example, perhaps your logging methods are called but the whole transaction is rolled back when the insert fails. You should be able to find this out by debugging the methods when you do the "duplicate insert".

    Error logging in AIF was way better than in D365 integrations - especially with Data Management Projects. But perhaps this difference doesn't have any negative impact on your business. During the upgrade you might need to solve some requirements differently than before.

  • pavel.stikhin Profile Picture
    pavel.stikhin 35 on at
    RE: Data Entity logs by errors

    Actually, it is no tragedy if FO would not get this information. I think It would denote a lack of consistentcy on the FO side.

    The logging is not possible, is that correct?

    Some other details

    The whole project is an upgrade DAX-2012 -> DAX-365 FO, and there was an AIF SOAP data transfer of DAX and external application. The DAX AIF logs there were consistent - containing both all the successful calls and failures.

    We are going to introduce a FO native integration approach via data entities, and from the beggining we run into the case.

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,148 on at
    RE: Data Entity logs by errors

    Ah, sorry, you are right - if you try to create a duplicate record via OData it will fail like this.

    So, the caller application already knows that the request failed.

    And it was a duplicate record which means no data is missing in D365.

    Why exactly do you want to log it in D365? Why would D365 need to care about this?

    In my opinion it's the calling application who should report the errors if you want them to be reported somewhere.

  • pavel.stikhin Profile Picture
    pavel.stikhin 35 on at
    RE: Data Entity logs by errors

    I am testing with postman, by sending the same POST request twice (multiple times) to a custom data entity.

    - sending the request for the fist time - creates a record. In the entity I have overloaded the following methods:

    pastedimage1622787622149v3.png

    in each of the methods a simple call to a custom log table is placed (creating a new log entry with text, indicating from wich method it has been called).

    Here an example how the log ("call stack") looks like after the insert (fist data entity call):

    pastedimage1622787658667v4.png

    - sending the request for the second time - no other entries appear in the log table ( hence the events were not fired). In postman I see the following error:

    "Write failed for table row of type '...TableEntity'. Infolog: Info: Cannot create a record in ... (...Table). ...: Test_2021060401, Test 20210604 01.\nThe record already exists.."

    I wonder if it is possible to get the log entries for this case (duplicating insert) or wich another approach on the FO side should be taken to make logs (protocolling) possible.

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,148 on at
    RE: Data Entity logs by errors

    If you import the same record again (=import a record with same key fields than existing record), it will update the existing record in D365. The import will not fail.

    If the import would fail, you would get an error message.

  • pavel.stikhin Profile Picture
    pavel.stikhin 35 on at
    RE: Data Entity logs by errors

    Hi Nikolaos

    Do you have an idea? Our problem is - we cann't catch on FO side a data entity call, which is failing (duplicate insert). No events seem to be fired in this case (are we wrong with the assumption?)

    Regards

  • pavel.stikhin Profile Picture
    pavel.stikhin 35 on at
    RE: Data Entity logs by errors

    We need help / advice in general idea / hints to implementation of a log for the simple data entity for the case, when the entity receives an "duplicating insert". In this situation no of the common entity methods seems to be called. So our simple table log (called from each of the standard methods) gets no record, which is not optimal for tracebility.

    The external application (sent this "duplicating insert") is getting a corresponding response (indicating the error) but we would like to catch it on the FO side as well.

  • nmaenpaa Profile Picture
    nmaenpaa 101,148 on at
    RE: Data Entity logs by errors

    About point 1, could you describe where exactly you need hints/help?

    Do you need help in:

    a) adding your custom code to run when the data entity is imported?

    b) figuring out whether the data is inserted or update?

    c) creating a custom log table?

    d) writing data to custom log table?

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,995 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,610 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans