function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

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() && != null) { StaticObjectHelper.setTriggerAlreadyFired(true); for(Case { 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.