How to restore a deleted database item.
26.01.2017

How to restore a deleted database item.

For example, the "Users" directory entry was deleted, after which in the orders of buyers, sales of goods and other documents in the "Responsible" requisition the value "Object not found (GUID code)".


You can suggest 2 ways to restore an erroneously deleted database item:
  1. Perform a database test with a logical integrity check. This will restore the database items that were deleted, but they were referenced in other elements of the database. When tested, they will be restored. Items that were deleted from the database and were not referenced in other database objects will not be restored.
  2. Programmatically (for the programmer). To do this, you should use the Set NewList (GUID Remote Element) function when creating a new entry in the directory. As a parameter, pass the GUID of the RemoteElement, which can be taken from any object where there is a reference to the remote object in the requisite. See the code example below.:

Procedure ButtonExecuteClick(Button)
       DirUsers = Directory.Users.CreateElement();
       DirUsers.Name=NameForNewElement;
       DirUsers.SetLinkNew(ObjectForLink.Responsible);
       DirUsers.Write();
       Report("Recorded:"+DirUsers.Link);
EndProcedure

 

Company "NCT"


Back to the list