Return to Snippet

Revision: 42676
at March 9, 2011 01:53 by garnold


Initial Code
//First create a list object to hold all the items that you would like to delete
System.Collections.Generic.IList deleteThese = new System.Collections.Generic.List();

deleteThese.Clear();

//If the parent has any children....
if (Parent.Child!= null)
{
   //Cycle through all the children and add their id's to the list you built above

   foreach (IChild c in Parent.Child)
   {
     deleteThese.Add(c.Id.ToString());
   }

   //Now we cycle through that list of ids...
   foreach (string s in deleteThese)
   {
     //First find the entity you want to delete by it's id
     IChild deleteMe = Sage.Platform.EntityFactory.GetById(s);

     //Next remove it from it's parent
     Parent.Cild.Remove(deleteMe);

     //Follow that by saving this change to the parent
     Parent.Save();

     //Then finally deleting the entity
     deleteMe.Delete();
   }
}

Initial URL


Initial Description


Initial Title
Deleting entities from SalesLogix

Initial Tags


Initial Language
C#