• OneMeggitt
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies

 

OK. I am new to this, but am missing something dumb. I know.

 

Class is ScottClass

 

I want to make a method that performs an account merge function.

Basically, I have two different fields on Accounts with the same number in it. I want to pull them together and merge them.

I can do it one by one, but I'm trying to make it a method.  I know it should be possible.

 

public class ScottClass {

public void mergeBasing (string ERPSTring){
Account masterAcct = [SELECT Id, SAPCIBER__c FROM Account WHERE SAPCIBER__c = :ERPString LIMIT 1];
Account mergeAcct = [SELECT Id, ERPBasing_C__c FROM Account WHERE ERPBasing_C__c = :ERPString LIMIT 1];
merge masterAcct mergeAcct;
}
}
ScottClass.mergeBasing('6763');

 

-------------- I know the queries are right, because I know this works:

public String ERPString = '14138';
Account masterAcct = [SELECT Id, SAPCIBER__c FROM Account WHERE SAPCIBER__c = :ERPString LIMIT 1];
Account mergeAcct = [SELECT Id, ERPBasing_C__c FROM Account WHERE ERPBasing_C__c = :ERPString LIMIT 1];
try {
merge masterAcct mergeAcct;
} catch (DmlException e) {
// Process exception here
}

I was able to install the app set up everything just fine.  However, when I change the status on an account to "Sign Up", it instantly changes to "Confirming" and I am not receiving any messages for the account.  What does this mean?