Get Deleted records

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Oleksii S.
    Member
    • Apr 2020
    • 43

    Get Deleted records

    Hello all,
    I need to obtain the list of deleted records through API or whatever UI.
    "Where deleted isTrue" doesn't work.
    Please, help to find a method.
  • esforim
    Active Community Member
    • Jan 2020
    • 2204

    #2
    Where does Delete record even get store? I don't see any "archive" or "trash bin" button or menu or field that "that show true".

    Only way I see it is from the Auth Log

    espocrm.com/#ActionHistoryRecord/

    The api would be at:
    espocrm.com/api/v1/AuthLogRecord/

    I tried a couple way to filter deleted=true but keep failing. I couldn't even filter is using "textFilter" which I find to work for other entity such as Contact. For example:
    espocrm.com/api/v1/Contact?textFilter=test
    Last edited by esforim; 08-04-2020, 08:25 AM.

    Comment

    • telecastg
      Active Community Member
      • Jun 2018
      • 907

      #3
      I don't know of any basic Espo version GUI method to do it, maybe with reports or workflows ? (I don't use the advanced pack so I can't tell).

      However, if you are willing to use other methods, that can easily be done using myPhpAdmin.

      Expo db tables contain a field "deleted" that when set to "1" makes the record appear as "deleted" for Espo, even though it will remain in the database until Espo does a "clean out" as specified in your preferences, so just run a simple select query on the table that you need.

      Comment


      • Nishan Perera
        Nishan Perera commented
        Editing a comment
        Best thing is to do is get the data from the db.
    • Oleksii S.
      Member
      • Apr 2020
      • 43

      #4
      Thanks. Unfortunately, all these means are not for the cloud instance, I see. Oddly.

      Comment

      • Oleksii S.
        Member
        • Apr 2020
        • 43

        #5
        Well, part of the function appeared to exist..
        Anybody knows how works all the thing?
        Click image for larger version

Name:	Image 08-05-15_22.jpg
Views:	1308
Size:	31.4 KB
ID:	61208

        Comment

        • esforim
          Active Community Member
          • Jan 2020
          • 2204

          #6
          I'm sure /#ActionHistoryRecord/ is available for cloud user, make no sense that it is blocked.

          How did you access that Mona Mary record? (aside from copying the URL before deleting it)

          Comment

          • Oleksii S.
            Member
            • Apr 2020
            • 43

            #7
            Originally posted by espcrm
            I'm sure /#ActionHistoryRecord/ is available for cloud user, make no sense that it is blocked.
            How did you access that Mona Mary record? (aside from copying the URL before deleting it)
            Exactly. This "backdoor" way. Just looking for the "front" one.
            #ActionHistoryRecord is absent in Entity Manager, what is not far from "blocked".

            Comment

            • esforim
              Active Community Member
              • Jan 2020
              • 2204

              #8
              Oh I see what you mean, haha. No it not backdoor way, it is only available to the Administration. I posted that URL to make it easier.

              If you go into "Administration > Action History" you will see it.

              I never logged in as non-administration so not sure if standard Users can access it using Role/Team.

              Comment


              • Oleksii S.
                Oleksii S. commented
                Editing a comment
                A-ha, now I see it, thanks Would try to dig in this ActionHistoryRecord through API, then.
            • Maximus
              Senior Member
              • Nov 2018
              • 2731

              #9
              Hi folks.
              For those EspoCRM users who are using not cloud instance, there is a possibility to activate the Action History Record entity for Report (required json file code change). Due to this, you might fetch a list of deleted records (see screenshot).

              Note. The cleanupActionHistoryPeriod by default is 15 days, so you won't be able to get these records with this way after this time (see the 'cleanupActionHistoryPeriod' parameter in the /data/config.php file).



              Attached Files

              Comment

              • Oleksii S.
                Member
                • Apr 2020
                • 43

                #10
                Thus, "It's possible to delete the record with the formula expression: deleted = 1."
                But at the same time, it is impossible to undelete the record with the formula expression deleted=0, due to the design, am I right?

                Comment

                • esforim
                  Active Community Member
                  • Jan 2020
                  • 2204

                  #11
                  Originally posted by Maximus
                  Note. The cleanupActionHistoryPeriod by default is 15 days, so you won't be able to get these records with this way after this time (see the 'cleanupActionHistoryPeriod' parameter in the /data/config.php file).
                  Didn't know this, time to activate it.

                  Does setting it to "0" disable it?

                  Not sure but is this the job that does that clean: Scheduled Jobs > Clean-up

                  Does it do other cleaning as well or just ActionHistory I wonder?
                  Last edited by esforim; 08-12-2020, 04:10 AM.

                  Comment

                  • Maximus
                    Senior Member
                    • Nov 2018
                    • 2731

                    #12
                    > Does setting it to "0" disable it?

                    No, there is no such ability. You can redefine the logic from the file /application/Espo/Jobs/Cleanup.php in the Custom directory by disabling this Job from the Run() function.

                    > Not sure but is this the job that does that clean: Scheduled Jobs > Clean-up?
                    > Does it do other cleaning as well or just ActionHistory I wonder?

                    Yes, Clean-up runs this process and many others. Please investigate this file /application/Espo/Jobs/Cleanup.php




                    Comment


                    • esforim
                      esforim commented
                      Editing a comment
                      Thank you. I guess for now I just increase the days.
                  • Oleksii S.
                    Member
                    • Apr 2020
                    • 43

                    #13
                    Hello all,
                    a question related to the topic - how to catch a Restore Record event by formula or Process?
                    Or select records which have been restored?
                    Or at least to mark the deleting record in time of deletion (to utilize in case it would be restored)?

                    Comment

                    • tothewine
                      Active Community Member
                      • Jan 2018
                      • 373

                      #14
                      Originally posted by Oleksii S.
                      Hello all,
                      a question related to the topic - how to catch a Restore Record event by formula or Process?
                      Or select records which have been restored?
                      Or at least to mark the deleting record in time of deletion (to utilize in case it would be restored)?
                      I don't know if espo updates the modifiedAt field when deleting but if you customize the server code there should be a deletion event available.

                      Comment

                      Working...