Posted By

garnold on 03/09/11


Tagged

delete entity SalesLogix


Versions (?)

Deleting entities from SalesLogix


 / Published in: C#
 

  1. //First create a list object to hold all the items that you would like to delete
  2. System.Collections.Generic.IList deleteThese = new System.Collections.Generic.List();
  3.  
  4. deleteThese.Clear();
  5.  
  6. //If the parent has any children....
  7. if (Parent.Child!= null)
  8. {
  9. //Cycle through all the children and add their id's to the list you built above
  10.  
  11. foreach (IChild c in Parent.Child)
  12. {
  13. deleteThese.Add(c.Id.ToString());
  14. }
  15.  
  16. //Now we cycle through that list of ids...
  17. foreach (string s in deleteThese)
  18. {
  19. //First find the entity you want to delete by it's id
  20. IChild deleteMe = Sage.Platform.EntityFactory.GetById(s);
  21.  
  22. //Next remove it from it's parent
  23. Parent.Cild.Remove(deleteMe);
  24.  
  25. //Follow that by saving this change to the parent
  26. Parent.Save();
  27.  
  28. //Then finally deleting the entity
  29. deleteMe.Delete();
  30. }
  31. }

Report this snippet  

You need to login to post a comment.