2

Can we merge two objects together ? Get fields from 1 object and put them in another object simultaneously deleting one.

for some reason we have two "contract" objects in salesforce and one has more fields than the other . The problem is that the one with more fields is unused so we have no records there. The object where we have fewer fields is fully populated. I want to put the fields from the "unpopulated" custom Object inside of the populated object.

  • 1
    I think you can do it manually. 1) Define merging criteria. 2) Prepare metadata change (like apex classes etc to start reference new fields) 3)Run a batch job that would merge data. 4) Remove references that left. 5) Remove unused object. But is that really necessary to do? What about just add a lookup? – kurunve Jan 18 '16 at 15:37
  • for some reason we have to contract objects in salesforce and one has more fields than the other . The problem is that the one with more fields is unused so we have no records there. The object where we have little amount of fields is fully populated. I want to put those fields inside of the populated object. – Greg Jan 18 '16 at 15:40
1

reading your comment my understanding is that you want to copy the fields from one object to another. This is possible using the metadata api. Please keep a backup of the xml files you are going to change, so that you can revert back if there are any issues. Steps to do so are:

  1. Create a project in eclipse or mavensmate - provide the org credentials.
  2. When choosing the metadata for the project include both the objects(the ones you want to merge). It is fine if you can include all the components in the org too(not recommended for large orgs).
  3. Lets call the small object from which you want to copy fields as A. The object with the more fields on which you want to add more fields be called B.
  4. Open the project in the IDE(Eclipse or mavensmate) - Expand the 'objects' folder. Click on the file of object A.
  5. In the opened xml file, it contains several tags. Choose all the content between the ----- TO . The xml can contain multiple field tags - one for each custom field in the object A. All of the will be placed adjacent to each other. So select content from the 1st "" to the last "" on the XML file. Copy the content.
  6. Open the xml file corresponding to the object B by clicking on the file with its name in the 'objects' folder.
  7. It too contains an xml structure similar to the previous one. This time paste the content copied from the earlier file into this file. Copy all the content after the last "".
  8. Save the changes to the server(Save the file).

If the save is successful you will see the object B with all the custom fields you have in object A. I have tried this out but I am not sure if al kind of fields are transferable by this method across objects. If the idea feels worth a shot, please give it a try. Hope this helps.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.