• mweiss
  • NEWBIE
  • 0 Points
  • Member since 2010

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

Hi, I keep getting the following error: "INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call", even though I am not specifying any Ids anywhere. It will occasionally run without error, but most of the time it encounters an error on the insert, usually for the same record each time (which shouldn't even come back in the queries).

 

Any insight on this would be greatly appreciated!

 

I have posted my code below.

 

List<Session__c> sessionsToUpdate = new List<Session__c>();
List<Revenue_Rec__c> revRecListToCreate = new List<Revenue_Rec__c>();

positiveSessions = [SELECT Id, Ready__c, ReadyHidden__c, Revenue__c, Department__c, Name, ProjectName__c
	FROM Session__c 
	WHERE Ready__c = True AND ReadyHidden__c = True AND LastModifiedDate > :processDate LIMIT 100];
		
negativeSessions = [SELECT Id, Ready__c, ReadyHidden__c, Revenue__c, Department__c, Name, ProjectName__c
	FROM Session__c 
	WHERE Ready__c = False AND ReadyHidden__c = True AND LastModifiedDate > :processDate LIMIT 100];
			
for ( Service_Session__c currentPosSession : positiveSessions ) {
	Revenue_Rec__c posRevRec = CreateRevRec('Milestone', currentPosSession.Revenue__c, currentPosSession.Department__c, currentPosSession.Id, currentPosSession.ProjectName__c, Date.today());

			//update the checkboxes on the session
			currentPosSession.ReadyHidden__c = False;
			
			sessionsToUpdate.add(currentPosSession);
			revRecListToCreate.add(posRevRecog);
			
		} //END FOR LOOP for ( Service_Session__c currentPositiveServiceSession : positiveServiceSessions ) {
		
		for ( Session__c currentNegSession : negativeSessions ) {
			Decimal revAmount = -currentNegSession.Revenue__c;
			Revenue_Rec__c negRevRec = CreateRevRec('Milestone', revAmount, currentNegSession.Department__c, currentNegSession.Id, currentNegSession.ProjectName__c, Date.today());
			
			//update the checkboxes on the service session
			currentNegSession.ReadyHidden__c = False;
			
			sessionsToUpdate.add(currentNegSession);
			revRecListToCreate.add(negRevRecog);
		
		} //END FOR LOOP for ( Session__c currentNegativeSession : negativeSessions ) {
	
insert revRecListToCreate;
update sessionsToUpdate;

 The create method called:

public Revenue_Rec__c CreateRevRecog (String rrType, Decimal revAmount, String dept, String sessId, String projName, Date postDate) {
		Revenue_Rec__c revRec = new Revenue_Rec__c();
		revRec.RevenueAmount__c = revAmount;
		revRec.Department__c = dept;
		System.debug(sessId);
		revRec.Session__c = sessId;
		revRec.PostDate__c = postDate;
		
		return revRec;				
	}

 

 

  • August 16, 2010
  • Like
  • 0

I am making an Answers portal and am having a difficult time finding how add some functionality to the question/reply objects. I would like to add some options for sorting (highest rated, lowest rated, etc.), disable replies for specific questions, and be able to schedule when a question will post, rather than it posting right when it is created.

 

Any suggestions?

I am using a tooltip component that uses sfdcPage.setHelp to populate it and handle the logic of when to show the help text. The problem that I am having with it is that it appears on the left side of the mouse and covers up the field that it corresponds to.

 

What I am wondering is if there is a way to shift the help text box to the right a specified number of pixels or something similar.

 

Thanks in advance for any help on this.

I am batching the data loader to do upserts to five objects, using external IDs that need to be unique so that I can make sure to reference the same salesforce records every time I run the upsert, since each time, some of the records will have some different values.

 

The problem I'm having is that sometimes the records are updated when a match is found that already exists, and sometimes it gives me the error "duplicate value found". It's about a 50/50 split between the outcome that I want and the error messages. In theory, I shouldn't ever get any error messages when I re-run the upsert, since it should just update the records to the new values.

 

Removing the unique restriction on the external ID is not an option for me, as it just defeats the purpose of me using one completely if more than one record can have it.

 

I haven't been able to find anything so far, so any help on this would be greatly appreciated.

I have a spreadsheet that I want to be able to use with the data loader to upsert multiple objects in Salesforce, which, as far as I can tell, is possible using Apex and triggers. I am wondering though that if I am creating three objects based on a row in a spreadsheet, if I can back out the first two objects created if the thrid one fails for some reason, since I would either want all three of them or none of them to exist.

 

Also, would Apex triggers be the best approach for using one spreadsheet to upsert multiple objects, or would it be better to create three separate spreadsheets and then use batch scripting to run the data loader with all three?

  • April 01, 2010
  • Like
  • 0

I am batching the data loader to do upserts to five objects, using external IDs that need to be unique so that I can make sure to reference the same salesforce records every time I run the upsert, since each time, some of the records will have some different values.

 

The problem I'm having is that sometimes the records are updated when a match is found that already exists, and sometimes it gives me the error "duplicate value found". It's about a 50/50 split between the outcome that I want and the error messages. In theory, I shouldn't ever get any error messages when I re-run the upsert, since it should just update the records to the new values.

 

Removing the unique restriction on the external ID is not an option for me, as it just defeats the purpose of me using one completely if more than one record can have it.

 

I haven't been able to find anything so far, so any help on this would be greatly appreciated.

Hi, I keep getting the following error: "INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call", even though I am not specifying any Ids anywhere. It will occasionally run without error, but most of the time it encounters an error on the insert, usually for the same record each time (which shouldn't even come back in the queries).

 

Any insight on this would be greatly appreciated!

 

I have posted my code below.

 

List<Session__c> sessionsToUpdate = new List<Session__c>();
List<Revenue_Rec__c> revRecListToCreate = new List<Revenue_Rec__c>();

positiveSessions = [SELECT Id, Ready__c, ReadyHidden__c, Revenue__c, Department__c, Name, ProjectName__c
	FROM Session__c 
	WHERE Ready__c = True AND ReadyHidden__c = True AND LastModifiedDate > :processDate LIMIT 100];
		
negativeSessions = [SELECT Id, Ready__c, ReadyHidden__c, Revenue__c, Department__c, Name, ProjectName__c
	FROM Session__c 
	WHERE Ready__c = False AND ReadyHidden__c = True AND LastModifiedDate > :processDate LIMIT 100];
			
for ( Service_Session__c currentPosSession : positiveSessions ) {
	Revenue_Rec__c posRevRec = CreateRevRec('Milestone', currentPosSession.Revenue__c, currentPosSession.Department__c, currentPosSession.Id, currentPosSession.ProjectName__c, Date.today());

			//update the checkboxes on the session
			currentPosSession.ReadyHidden__c = False;
			
			sessionsToUpdate.add(currentPosSession);
			revRecListToCreate.add(posRevRecog);
			
		} //END FOR LOOP for ( Service_Session__c currentPositiveServiceSession : positiveServiceSessions ) {
		
		for ( Session__c currentNegSession : negativeSessions ) {
			Decimal revAmount = -currentNegSession.Revenue__c;
			Revenue_Rec__c negRevRec = CreateRevRec('Milestone', revAmount, currentNegSession.Department__c, currentNegSession.Id, currentNegSession.ProjectName__c, Date.today());
			
			//update the checkboxes on the service session
			currentNegSession.ReadyHidden__c = False;
			
			sessionsToUpdate.add(currentNegSession);
			revRecListToCreate.add(negRevRecog);
		
		} //END FOR LOOP for ( Session__c currentNegativeSession : negativeSessions ) {
	
insert revRecListToCreate;
update sessionsToUpdate;

 The create method called:

public Revenue_Rec__c CreateRevRecog (String rrType, Decimal revAmount, String dept, String sessId, String projName, Date postDate) {
		Revenue_Rec__c revRec = new Revenue_Rec__c();
		revRec.RevenueAmount__c = revAmount;
		revRec.Department__c = dept;
		System.debug(sessId);
		revRec.Session__c = sessId;
		revRec.PostDate__c = postDate;
		
		return revRec;				
	}

 

 

  • August 16, 2010
  • Like
  • 0

I am making an Answers portal and am having a difficult time finding how add some functionality to the question/reply objects. I would like to add some options for sorting (highest rated, lowest rated, etc.), disable replies for specific questions, and be able to schedule when a question will post, rather than it posting right when it is created.

 

Any suggestions?

I am batching the data loader to do upserts to five objects, using external IDs that need to be unique so that I can make sure to reference the same salesforce records every time I run the upsert, since each time, some of the records will have some different values.

 

The problem I'm having is that sometimes the records are updated when a match is found that already exists, and sometimes it gives me the error "duplicate value found". It's about a 50/50 split between the outcome that I want and the error messages. In theory, I shouldn't ever get any error messages when I re-run the upsert, since it should just update the records to the new values.

 

Removing the unique restriction on the external ID is not an option for me, as it just defeats the purpose of me using one completely if more than one record can have it.

 

I haven't been able to find anything so far, so any help on this would be greatly appreciated.

I have a spreadsheet that I want to be able to use with the data loader to upsert multiple objects in Salesforce, which, as far as I can tell, is possible using Apex and triggers. I am wondering though that if I am creating three objects based on a row in a spreadsheet, if I can back out the first two objects created if the thrid one fails for some reason, since I would either want all three of them or none of them to exist.

 

Also, would Apex triggers be the best approach for using one spreadsheet to upsert multiple objects, or would it be better to create three separate spreadsheets and then use batch scripting to run the data loader with all three?

  • April 01, 2010
  • Like
  • 0

I have a dataloader job that does a upsert on contact.  It tries to match on a unique external ID call CBC_ID__C.  I am pretty regularly getting contact upsert errors on some records and the error message is something like:

 

duplicate value found: CBC_Id__c duplicates value on record with id: 0036000000sNLHF

 

When I try to look up the SF record with ID 0036000000sNLHF, it does not exist.  Does any one know what the deal is?

 

Thanks