This was developed on CRM 2007 and may work on CRM 4.0
A quite common problem in the last projects was the lack of standard functionality to copy trees of BOL nodes dynamically.
This is for example necessary when editing sales area data of business partners. Sales Area data often contains many fields or tables which have to be maintained for each Sales Area. The most of the fields are however similar for more than one sales area and it might be interesting to copy the values from one Sales Area to another.
This example shall explain how to copy the data from one object to another.
Declares the local data:
Gets the components loaded and fetches the sub relations and assignes it to relations table
fetch all child objects and append to table
Create a new BuilSalesArrangement object
Bind the newly created object to BP
Now we have to fill the newly created object and create child objects containing the copied values from the original object. In order to do this two loops can be used: First loop through all possible sub objects and loop in a inner loop throught the entities in the entity collection