• EBeach
  • NEWBIE
  • 25 Points
  • Member since 2009

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies

Our problem: we need all records of a custom object related to the lead to map to the contact/account/opportunity on lead convert.

 

Attempted solution: an app from hiSoft (http://sites.force.com/appexchange/listingDetail?listingId=a0N30000003GuisEAC)

This app creates a new custom object with lookup fields for Lead, Contact, Account and Opportunity.

It also includes the Trigger below.  This trigger only seems to update a single record of all records of the custom object related to the lead.  I don't understand why as the map should pull all custom object records for the lead Id.  Any recommendations of why this trigger isn't functioning properly?

 

 

trigger UpdateCustomeObject_Trigger on Lead (before update) {

	for (Integer i = 0; i < Trigger.new.size(); i++){
	    if (Trigger.new[i].IsConverted == true && Trigger.old[i].isConverted == false){
		    Set<Id> leadIds = new Set<Id>();
		    for (Lead lead : Trigger.new) {
		        leadIds.add(lead.Id);
		    }
		    
		    Map<Id, CustomObject__c> entries = new Map<Id, CustomObject__c>([select Contact__c, Opportunity__c, Account__c, Lead__c from CustomObject__c where lead__c in :leadIds]);        
		    if(!Trigger.new.isEmpty()) {
			    for (Lead lead : Trigger.new)  {
			    	for (CustomObject__c CustomObject : entries.values()) {
			    		if (CustomObject.Lead__c == lead.Id) {
					        CustomObject.contact__c = lead.ConvertedContactId;
					        CustomObject.opportunity__c = lead.ConvertedOpportunityId;
					        CustomObject.account__c = lead.ConvertedAccountId;
					        update CustomObject;
					        break;
			    		}
			    	}
			    }
		    }
	    }
    }
}

 

 

  • November 15, 2010
  • Like
  • 0

We're cloning a custom quote object record with a button that references an Apex Class.  Currently the clone button results in creating a cloned record with the default record type.  I would like to specify that the record type of the original record is also the record type of the cloned record.

 

Is this possible?

  • August 25, 2010
  • Like
  • 0

Our problem: we need all records of a custom object related to the lead to map to the contact/account/opportunity on lead convert.

 

Attempted solution: an app from hiSoft (http://sites.force.com/appexchange/listingDetail?listingId=a0N30000003GuisEAC)

This app creates a new custom object with lookup fields for Lead, Contact, Account and Opportunity.

It also includes the Trigger below.  This trigger only seems to update a single record of all records of the custom object related to the lead.  I don't understand why as the map should pull all custom object records for the lead Id.  Any recommendations of why this trigger isn't functioning properly?

 

 

trigger UpdateCustomeObject_Trigger on Lead (before update) {

	for (Integer i = 0; i < Trigger.new.size(); i++){
	    if (Trigger.new[i].IsConverted == true && Trigger.old[i].isConverted == false){
		    Set<Id> leadIds = new Set<Id>();
		    for (Lead lead : Trigger.new) {
		        leadIds.add(lead.Id);
		    }
		    
		    Map<Id, CustomObject__c> entries = new Map<Id, CustomObject__c>([select Contact__c, Opportunity__c, Account__c, Lead__c from CustomObject__c where lead__c in :leadIds]);        
		    if(!Trigger.new.isEmpty()) {
			    for (Lead lead : Trigger.new)  {
			    	for (CustomObject__c CustomObject : entries.values()) {
			    		if (CustomObject.Lead__c == lead.Id) {
					        CustomObject.contact__c = lead.ConvertedContactId;
					        CustomObject.opportunity__c = lead.ConvertedOpportunityId;
					        CustomObject.account__c = lead.ConvertedAccountId;
					        update CustomObject;
					        break;
			    		}
			    	}
			    }
		    }
	    }
    }
}

 

 

  • November 15, 2010
  • Like
  • 0

Hey ho,

 

I am striving problems while trying to install Smart Follow. I enabled chatter and then tried to install the app via the AppExchange.

 

The installer fails with this error:

 

 

Problem:

1. Apex Classes(01p20000000TZcU) chatterfollowrules.testFollowDepartment();
chatterfollowrules.testFollowEveryone();
chatterfollowrules.testFollowManagerHierarchy();
chatterfollowrules.testFollowProfile();
chatterfollowrules.testFollowRole();
chatterfollowrules.testTeamfollowRule()
System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: SetupOwnerId duplicates value on record with id: 00D200000000NNy: []
Class.chatterFollowRules.testFollowDepartment: line 819, column 13 External entry point;
System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: SetupOwnerId duplicates value on record with id: 00D200000000NNy: []
Class.chatterFollowRules.testFollowEveryone: line 627, column 13 External entry point;
System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: SetupOwnerId duplicates value on record with id: 00D200000000NNy: []
Class.chatterFollowRules.testFollowManagerHierarchy: line 474, column 13 External entry point;
System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: SetupOwnerId duplicates value on record with id: 00D200000000NNy: []
Class.chatterFollowRules.testFollowProfile: line 759, column 13 External entry point;
System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: SetupOwnerId duplicates value on record with id: 00D200000000NNy: []
Class.chatterFollowRules.testFollowRole: line 667, column 13 External entry point;
System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: SetupOwnerId duplicates value on record with id: 00D200000000NNy: []
Class.chatterFollowRules.testTeamfollowRule: line 403, column 13 External entry point

2. Apex Classes(01p20000000TZcO) chatterfollowbatchcaller.testchatterFollowBatchCaller()
System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: SetupOwnerId duplicates value on record with id: 00D200000000NNy: []
Class.chatterFollowBatchCaller.updateSettings: line 58, column 4
Class.chatterFollowBatchCaller.testchatterFollowBatchCaller: line 128, column 3 External entry point



Validation Errors While Saving Record(s)

There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "00D200000000NNy: APEX_TEST_FAILED [01p20000000TZcU: chatterfollowrules.testFollowDepartment();
chatterfollowrules.testFollowEveryone();
chatterfollowrules.testFollowManagerHierarchy();
chatterfollowrules.testFollowProfile();
chatterfollowrules.testFollowRole();
chatterfollowrules.testTeamfollowRule(): System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: SetupOwnerId duplicates value on record with id: 00D200000000NNy: []
Class.chatterFollowRules.testFollowDepartment: line 819, column 13 External entry point;
System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: SetupOwnerId duplicates value on record with id: 00D200000000NNy: []
Class.chatterFollowRules.testFollowEveryone: line 627, column 13 External entry point;
System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: SetupOwnerId duplicates value on record with id: 00D200000000NNy: []
Class.chatterFollowRules.testFollowManagerHierarchy: line 474, column 13 External entry point;
System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: SetupOwnerId duplicates value on record with id: 00D200000000NNy: []
Class.chatterFollowRules.testFollowProfile: line 759, column 13 External entry point;
System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: SetupOwnerId duplicates value on record with id: 00D200000000NNy: []
Class.chatterFollowRules.testFollowRole: line 667, column 13 External entry point;
System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: SetupOwnerId duplicates value on record with id: 00D200000000NNy: []
Class.chatterFollowRules.testTeamfollowRule: line 403, column 13 External entry point, 01p20000000TZcO: chatterfollowbatchcaller.testchatterFollowBatchCaller(): System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: SetupOwnerId duplicates value on record with id: 00D200000000NNy: []
Class.chatterFollowBatchCaller.updateSettings: line 58, column 4
Class.chatterFollowBatchCaller.testchatterFollowBatchCaller: line 128, column 3 External entry point]".

 

 

 

And when I choose to install the app with "Ignore Tests" I cannot create follow rules;

 

 

Visualforce Page: /apex/chatterFollow



caused by: System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: SetupOwnerId duplicates value on record with id: 00D200000000NNy: []

Class.chatterFollowBatchCaller.updateSettings: line 58, column 4 External entry point

 

We are on EMEA. I can send my org. ID via PM if needed.

 

 

So, looks like I am not taking Chatter live today :(

 

Cheers,

Hannes