Delete company trigger

WildcardWildcard Member Posts: 26
Hi all,

There is a possibility to know when a user delete a company?
The reason is the following: I have table with datapercompany no and they are related with the company who is deleted. I would like to delete those obsolete lines.

Thanks for your help.

Wildcard

Answers

  • krikikriki Member, Moderator Posts: 9,110
    Don't allow them to delete companies! It should be done only by people who know what they are doing and why they are doing it.

    You make it sound that it is something that users do regularly. But it is something that should be done with great care!
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    I agree, first you should try to solve it by user rights.

    If that's not an option you could add some code in OnDelete of Table 2000000006 Company.
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • WildcardWildcard Member Posts: 26
    kriki wrote:
    Don't allow them to delete companies! It should be done only by people who know what they are doing and why they are doing it.

    You make it sound that it is something that users do regularly. But it is something that should be done with great care!
    Thanks for the answer.

    Of course they are not allowed to do it, it's our internal test database. We make a lot of test with different company. We delete those unwanted data each time. The purpose of this it's to gain time and avoid unneccessary data, sometimes we forget.
    This code will not be necessary in production environement.
    If that's not an option you could add some code in OnDelete of Table 2000000006 Company.
    Thanks I will try this.

    Wildcard
  • rhpntrhpnt Member Posts: 688
    Or maybe you should leave the "data per company" property set to "yes".
  • WildcardWildcard Member Posts: 26
    With the ondelete on table 2000000006 it's working.
    Thank you very much.


    Thanks for worring for this case. :)
    But we really need datapercompany to yes.
  • krikikriki Member, Moderator Posts: 9,110
    Instead of touching the company-table, I would create a report that checks and fixes all.
    Because if you change the Company-table for developing-only. Sooner or later it will make its way into the customers production DB and that is probably not a good idea.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    I agree with you that you should avoid any changes to standard objects as long as it's possible.
    In this case it's a question of elaborateness. Everybody who works with those databases should be aware of the fact that it's not allowed to copy objects from those databases into any live system. That should be the highest priority. You could add some special tag to the version list as well.
    And you have to think of what would happen. Deleting a company is not a very common task. So, in worst case and the objects were copied into some live databases the only thing that would arise is your customer will call you up and tell you that there is an error message. Because deleting a company is never a time-critical process that shouldn't be any issue.
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • WildcardWildcard Member Posts: 26
    We are aware from this. Thank you.
    We have one person who is in charge of passing object to other database and he is aware on this.
    The datapercompany =yes is on our specific object.
    Deleting a company will be never done by a customer and never on a live database. (Maybe if we got troube but it's not planned :))

    It's for our test we need this, so we don't have to correct those data each time we make test. Like we did before.

    Thanks for your advice !
Sign In or Register to comment.