You need to sign in to do that
Don't have an account?
Problem with updating record type via trigger
I have a trigger that updates the case after it's been submitted, but what's not working is updating the record type. I've tried it a couple different ways and none of them seem to work. Here's the code: Thanks in advance.
trigger updateSponsor on Case (after update) { if (!StaticObjectHelper.getTriggerAlreadyFired() && Trigger.new != null) { StaticObjectHelper.setTriggerAlreadyFired(true); for(Case myCase:trigger.new) { system.debug(myCase); //if (myCase.RecordTypeId == '012300000003H1VAAU') if(myCase.Type_of_Applicant__c != null) { Case sponsorOnCase = new Case (Id = myCase.Id); sponsorOnCase.Sponsor__c = myCase.CreatedById; sponsorOnCase.RecordTypeId = '012300000003VO1'; //mycase.RecordTypeID = '012300000003VO1'; system.debug(sponsorOnCase.Sponsor__c); update sponsorOnCase; system.debug(sponsorOnCase); }// else nothing } } }
This looks like a really complicated trigger. Why not make it a before update trigger and save yourself a lot of code? Then you can adjust anything you'd like.
As for why the others work but not the record type, I have no answer, but it may have something to do with you performing an after update action on the base trigger object instead of before update.