• SmartPlayer
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies
I am trying to figure out how to pass the ID of an existing record I am trying to update. I get the above error in the debug logs after running this method.

As a background, I have a trigger after update running the passes trigger.new into a method called MarqueeUpdate. From there, I query to find the existing ChangeRecord__c. I need the ID of that ChangeRecord__c to update. 

I cannot figure out how to pass the id of that record to my update statement. 
//Updating existing records
    public static void MarqueeUpdate(List<NI_MarqueeFeature__c> marqueeUpdate){ 
        
        //marqueeUpdate contains trigger.new
        for (NI_MarqueeFeature__c mi : marqueeUpdate){
            String Id = mi.Id;
            List <ChangeRecord__c>  upMarquee = [SELECT ID
                    				 FROM ChangeRecord__c
                				 WHERE ChangeRecord__c.ID__c = :Id];
            
                    if (marqueeUpdate.size()>0) {
                        ChangeRecord__c um = new ChangeRecord__c ();
                        
                        um.ID__c = mi.id;
                        um.LastMod__c = mi.LastModifiedDate;
                        
                        upMarquee.add(um);
                        
                        try {
                            update um;
                          } catch (system.DmlException e) {
                            system.debug (e);}
        }
        }
    }

Our organization would like to convert all Person Accounts to Contacts. We would like the converted contact to be connect to an account named, "Generic Contact."  I looked into this a little and this is what I found out. 

 

Option 1:

Each Person Account has a record in both the Account table and Contact table.  The Contact table holds all the Person Acount information.  The Contact table has a field called IsPersonAccount which is marked true. I would like to change the IsPersonAccount to false, change the AccountId to that of the "Generic Contact" account and Delete the Account with the old AccountId.

 

Whenever I try to change the IsPersonAccount to false, I get an error "INVALID_FIELD_FOR_INSERT_UPDATE".

 

Option 2:

Now I can export the contacts to a csv file and  filter out all contacts with business accounts leaving the Person Accounts.  Then I can delete all Person Accounts and import the people in my csv file as contacts.  Finally, reconnect all compaigns using the PHP API.  

 

 

I would much rather change the AccountId and IsPersonAccount fields  (much less work).  Is there anyway to do option 1 or is there a better way of converting PersonAccounts to Contacts?