• Michael Meinhardt
  • NEWBIE
  • 0 Points
  • Member since 2014

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

Currently we update our accounts on salesforce by an automatic batch that use data loader.
We do an insert of our new accounts each day.
Then we recuperate the salesforce ID for each account.
And finally we do an update of accounts.

We would like to use the functionnality upsert to simplify the treatment. We can create an external ID on salesforce with our ID to use upsert.
I doesn't test this part but I have no problem with this.
My problem is because we have a hierarchical field on account.
So if we use our id for an upsert I still need the Salesforce id for the hierarchical field. 
Could we use the external id (our id) for the hierarchical information too please? And how can I do that?

Thanks for your help.

Hi everyone , 

Im an apex noob,  and have just started a position in a company that uses salesforce for its CRM,  Unfortunately my predecessor left without handing over the salesforce reigns and I have been tasked with trying to change an email address in the code.  However when i change the address and try to reupload the code,  it goes to the sandbox without any problems,  however when it goes to the production server I get the message that there is a system Dml exception due to an inactive owner or user.  I have checked salesforce for the status of those that wrote the original code and they are all down as active ( despite being no longer with the company )..  The error seams to come in the testing code.

I would like to teach myself salesforce development however this one error is a giant brick wall to me. I have posted the code below,  can anybody give me some pointers in how to overcome this.

 

@isTest
private class vf_testing {

    static testMethod void myUnitTestofmultiple() {
        // TO DO: implement unit test
        caserefs igor = new caserefs();
        igor.caser='123';
        igor.poster='456';
     }
     
     static testMethod void testingextra_dates(){
     Account Fred = new Account(LastName='Flintstoned');
     insert Fred;
     ID whom=Fred.Id;
     Account kgm = new Account(Name='KGM');
     insert kgm;
     ID insurer=kgm.id;
     Opportunity Barney = new Opportunity(Name='Flintstoned', AccountId=whom, Insurer_prefix__c='KGM', Insurer__c=insurer, Case_referral_type__c='Unrecovered Theft', Business_Unit__c='Motor', Claim_Ref__c='430640', StageName='Claims Support', Date_of_Loss__c=date.today(), CloseDate=date.today());
     insert Barney;
     Opportunity rei =[select id, name, estimatediscovery__c, account.personmailingstreet, account.PersonMailingCity, account.personmailingstate, account.personmailingpostalcode, Insurer_prefix__c, insurer__c, Case_referral_type__c, Business_Unit__c, case_file_long_reference__c, StageName, Date_of_Loss__c, AccountId from opportunity where id=:barney.id];
     system.debug(rei.case_file_long_reference__c);
     ApexPages.StandardController pebbles=new ApexPages.StandardController(rei);
     extra_dates_opp bambam = new extra_dates_opp(pebbles);
     bambam.setappDriskAddr(false);
     bambam.setappDstreet('Street name');
     String name=bambam.getappDstreet();
     bambam.setappDcity('Street name');
     name=bambam.getappDcity();
     bambam.setappDcounty('Street name');
     name=bambam.getappDcounty();
     bambam.setappDpostcode('Street name');
     name=bambam.getappDpostcode();
     bambam.setappDuk('Street name');
     name=bambam.getappDuk();
     boolean isaddr=bambam.getappDriskaddr();
     bambam.setappDriskAddr(true);
     name=bambam.getappDstreet();
     name=bambam.getappDcity();
     name=bambam.getappDcounty();
     name=bambam.getappDpostcode();
     bambam.setappDstreet('Street name');
     bambam.setappDcity('Street name');
     bambam.setappDcounty('Street name');
     bambam.setappDpostcode('Street name');
     bambam.setappDcircs('Event');
     name=bambam.getappDcircs();
     name=bambam.getincidentwords();
     bambam.setincidentwords('incidentwords');
     name=bambam.getHTMLinfo();
     PageReference bexbex=bambam.PDFHH14();
     name=bambam.getapprox();
     name=bambam.getlongdate();
     name=bambam.getlossdate();
     bambam.nullme();
     PageReference nowhere=bambam.pdfme();
     name=bambam.getInsDial();
     name=bambam.getInsFormal();
     name=bambam.chooseInsName('EC');
     name=bambam.Choose0845('EC');
     name=bambam.chooseInsName('KG');
     name=bambam.Choose0845('KG');
     name=bambam.chooseInsName('MG');
     name=bambam.Choose0845('MG');
     name=bambam.chooseInsName('EI');
     name=bambam.Choose0845('EI');
     name=bambam.chooseInsName('CS');
     name=bambam.Choose0845('CS');
     name=bambam.chooseInsName('HS');
     name=bambam.Choose0845('HS');
     name=bambam.chooseInsName('RS');
     name=bambam.Choose0845('RS');
     name=bambam.chooseInsName('EQ');
     name=bambam.Choose0845('EQ');
     name=bambam.ChooseInsName('EM');
     name=bambam.Choose0845('EM');
     name=bambam.chooseInsName('HT');
     name=bambam.Choose0845('HT');
     name=bambam.Choose0845('EP');
     name=bambam.chooseInsName('XX');
     name=bambam.Choose0845('XX');
     name=bambam.gettype_of_incident();
     name=bambam.gettype_of_hhincident();
     name=bambam.incwords('MAD');
     name=bambam.incwords('SANE');
     name=bambam.hhincwords('HAL');
     name=bambam.hhincwords('HAD');
     name=bambam.hhincwords('HUM');
     }
     
     static testMethod void testingmulti_insert(){
     	Account Fred = new Account(LastName='Flintstoned');
     insert Fred;
     ID whom=Fred.Id;
     Account kgm = new Account(Name='KGM');
     insert kgm;
     ID insurer=kgm.id;
     Opportunity Barney = new Opportunity(Name='Flintstoned', AccountId=whom, Insurer_prefix__c='KGM', Insurer__c=insurer, Case_referral_type__c='Unrecovered Theft', Claim_Ref__c='430640', StageName='Claims Support', Date_of_Loss__c=date.today(), CloseDate=date.today());
     insert Barney;
     String caseref=Barney.Claim_Ref__c;
     system.debug(caseref);
     system.debug(Barney.Case_file_long_reference__c);
     	multi_insert pile=new multi_insert();
     	RecordTypeListCon types=new RecordTypeListCon();
     	types.sObjectType='Account';
     	List<SelectOption> screed=pile.gettypes();
     	screed=types.getItems();
     	pile.setSubject('Subjective');
     	String subj=pile.getSubject();
     	PageReference nowhere=pile.cancel();
     	boolean tick=pile.getDocreturns();
     	pile.setDocreturns(tick);
     	pile.addrow();
     	pile.removerow();
     	pile.cases[0].caser=caseref;
     	pile.cases[0].docser=true;
     	pile.docReturns=true;
     	pile.save();
     	pile.savepost();
     	pile.saveemail();
     	pile.clearout();
     	//Split here as the SOQL count is getting high.
     }
     
     static testMethod void testingmulti_insert2(){
     	Account Fred = new Account(LastName='Flintstoned');
     insert Fred;
     ID whom=Fred.Id;
     Account kgm = new Account(Name='KGM');
     insert kgm;
     ID insurer=kgm.id;
     Opportunity Barney = new Opportunity(Name='Flintstoned', AccountId=whom, Insurer_prefix__c='KGM', Insurer__c=insurer, Case_referral_type__c='Unrecovered Theft', Claim_Ref__c='430640', StageName='Claims Support', Date_of_Loss__c=date.today(), CloseDate=date.today());
     insert Barney;
     String caseref=Barney.Claim_Ref__c;
     system.debug(caseref);
     system.debug(Barney.Case_file_long_reference__c);
     	multi_insert pile=new multi_insert();
     	pile.cases[0].caser='bogus';
     	pile.save();
     	pile.cases[0].caser='430640';
     	pile.setSubject('Documents Received');
     	pile.save();
     	pile.outg();
     	pile.setSubject('1st Class Post');
     	pile.redticket=true;
     	pile.outg();
     	pile.setSubject('2nd Class Post');
     	pile.outg();
     	pile.setSubject('1st Class Packet');
     	pile.outg();
     	pile.numitems=1;
     	pile.totalcost=10.0;
     	pile.docReturns=true;
     	pile.outg();
     }
     
}

 It seams to bounce its issue against 

testingmulti_insert

                     SystemDmlException:Insert failed: First exception on row 1; first error:INACTIVE_OWNER_OR_USER. operation performed with inactive user.

                                                   Class.multi_insert.saveemail:line 176, column 1

 

Any help would be greatly and desperately appreciated

 

:)

 

Note : even if i change nothing and trying to send it back to the server I get the same error.