You need to sign in to do that
Don't have an account?
jonathanbernddf20131.387825590468351E12
Help to bulkify working trigger better
Hi folks
Still new but getting there bit by bit. I have this trigger, It is supposed to update certain specific fields based on different picklist values. I'm thinking it's not bulkified like it should be. I'm thinking (but could be wrong) I need to make a set/list and update the values of the set before letting it go ahead and do it's stuff, so I can do everything with one update. Here's the trigger.
trigger updateAppNum on CustomObject__c (before insert, before update) {
//Get set of Incomplete ids
List<Integer> appUps = new List<Integer>();
for(CustomObject__c ap :trigger.new) {
if (ap.Status__c == 'Incomplete') {
ap.AppInc__c = 1;
}
if (ap.Status__c == 'Complete - Pending Review') {
ap.AppCompP__c = 1;
}
if (ap.Status__c == 'Complete - Decision Made') {
ap.AppCompD__c = 1;
}
if (ap.Status__c == 'Deferred') {
ap.AppDef__c = 1;
}
if (ap.Status__c == 'Withdrawn') {
ap.AppW__c = 1;
}
}
}
Still new but getting there bit by bit. I have this trigger, It is supposed to update certain specific fields based on different picklist values. I'm thinking it's not bulkified like it should be. I'm thinking (but could be wrong) I need to make a set/list and update the values of the set before letting it go ahead and do it's stuff, so I can do everything with one update. Here's the trigger.
trigger updateAppNum on CustomObject__c (before insert, before update) {
//Get set of Incomplete ids
List<Integer> appUps = new List<Integer>();
for(CustomObject__c ap :trigger.new) {
if (ap.Status__c == 'Incomplete') {
ap.AppInc__c = 1;
}
if (ap.Status__c == 'Complete - Pending Review') {
ap.AppCompP__c = 1;
}
if (ap.Status__c == 'Complete - Decision Made') {
ap.AppCompD__c = 1;
}
if (ap.Status__c == 'Deferred') {
ap.AppDef__c = 1;
}
if (ap.Status__c == 'Withdrawn') {
ap.AppW__c = 1;
}
}
}
All Answers