function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jonathanrico.jonathanrico. 

An Apex merge/replace class for all of you ;)

Hello everyone, I've recieved nothing but great feedback from the autocomplete component I posted previously here in the discussion boards. So here's something else I would like to share with you.

 

Apex Object Merge Class

 

This apex class allows merge operations on a any custom object, please feel free to read more about it here:

 

http://jonathanrm.com/2010/02/force-com-apex-mergereplace-class/

Message Edited by jonathan rico on 02-07-2010 01:54 PM
VarunCVarunC

thanks jonathan for your efforts :) ...

 

I tried using this but unluckily got errors all the way when using it ... MAY BE I don't know how to use the cod eproperly here ... 

 

This is what I did, I created a custom Detail Button (on Contact as demo of yours is for Contact), and called DemoVF page of your on it. But I got this error:

 

Too many fields describes: 11

 

Can u guide me here about where and how the code of your is to be used ?

 

jonathanrico.jonathanrico.

Hi

 

In order to determine the relationships and fields dynamically i'm using several describe calls. I just noticed a way to reduce the describe calls,  I'll update the code in a couple of hours and let's see if this is fixed after the modifications.

 

By the way, do you have objects with a master-detail relationship to your Contact object? 

 

 

 

 

jonathanrico.jonathanrico.

Updated, please use the new ObjectMerge class.

Let me know if the fix works for you.

 

Thank you. 

VarunCVarunC

Sorry jonathan same error :( .... may be I'm using the code in wrong way. How do u suggest using the DemoPage code?

 

And I don't think I have any Master-Detail relationship in Contacts. Only relationship of master-Detail status I can think of is AccountID ...

jonathanrico.jonathanrico.

How many custom objects do you have related to your Contact?

 

Seems that your number of relations is causing more than 11 describe calls, and this is a limitation of the force.com platform.  

 

This is still one of the limitations of the class... i'm trying to figure out how to get around it but I don't know if it is possible. I wish the limit of 11 calls could be expanded.. 

VarunCVarunC
Ah yes . .sorry .. i got multiple Lookup relationships of Contact in multiple Custom Objects ... may be around 20+ in my org. I'll try to use the merge on another object for testing .... :)
jonathanrico.jonathanrico.

I see , then this is definitely causing the exception :S

 

Let me know how your testing goes then. I'll let you know if I find a way of decreasing the number of describe calls to avoid hitting this limit..