You need to sign in to do that
Don't have an account?
Dataloader error for product trigger
When i try update the data using data loader it was showing the error
ProductFieldUpdate: execution of BeforeUpdate
caused by: System.NullPointerException: Attempt to de-reference a null object
Trigger.ProductFieldUpdate: line 17, column 1
Code
trigger ProductFieldUpdate on Product2 (Before insert, before update){
for(Product2 p : trigger.new){
if(p.Ampics_PL__c != null && p.Ampics_PL__c == 'UTILUX' ) {
if(p.description.lastIndexOf('/') != -1) {
Integer lastIndx = p.description.lastIndexOf('/');
p.GPL_Desc__c = string.valueOf(p.description.subString(lastIndx + 1));
}
else {
p.GPL_Desc__c = '1';
}
}
}
}
trigger ProductFieldUpdate on Product2 (Before insert, before update){
for(Product2 p : trigger.new){
if(p.Ampics_PL__c != null && p.Ampics_PL__c == 'UTILUX' ) {
if(p.description!= null && p.description.lastIndexOf('/') != -1) {
Integer lastIndx = p.description.lastIndexOf('/');
p.GPL_Desc__c = string.valueOf(p.description.subString(lastIndx + 1));
}
else {
p.GPL_Desc__c = '1';
}
}
}
}