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

Change a trigger in a managed package

Hello everyone!


I'm going to do my first managed package...But I have a situation!


One of my triggers has a RecordTypeId hard-coded (yes, I know I didn't have to do it, but I did....)


My question is, can I change the trigger once It is installed in the new Org, or It's going to fail forever and ever?!?!?


Thanks in advance!

Best Answer chosen by Admin (Salesforce Developers) 

No, you cannot change the code.


The better way is to look up the record type Id with its own query.  I have a place where I need to retrieve four different record type id's. The code is below.


    ID dealerId = null;
ID fabricatorId = null;
ID distributorId = null;
ID dealerFabricatorId = null;

RecordType[] recordTypes = [
select id, Name
from recordtype
where sObjectType = 'Account'
and Name in : recordTypeNames];

for (RecordType recordType : recordTypes) {
if (recordType.Name == 'Distributor') {
distributorId = recordType.Id;
else if (recordType.Name == 'Dealer') {
dealerId = recordType.Id;
else if (recordType.Name == 'Dealer/Fabricator') {
dealerFabricatorId =;
else {
fabricatorId = recordType.Id;

 You also should have code to handle when the record type is not found.