You need to sign in to do that
Don't have an account?
Error in trigger
i want to split the value of one custom field and assaign the value to the other custom field which are related to product obj
trigger Compare_OldandNewvalues on Product2 (before update) {
for (Product2 prod: Trigger.new) {
// if(prod.Ampics_PL__c != Ampics_PL__c.Ampics_PL__c) {
// prod.Ampics_PL__c = Trigger.product2.get(prod.ID);
// String str = 'Utilix';
// String[] sstr = str.split('/');
// system.debug(sstr[0]);
// system.debug(sstr[1]);
// prod.Ampics_PL__c = 'sstr[1]';
// System.debug('--*Product Value is changed*--');
// System.debug('**Ampics_PL__c :'+Ampics_PL__c.sstr[0]);
// System.debug('**Ampics_PL__c :'+prod.sstr[0]);
}
}
// else{
// System.debug('--**Product2 Number has not been Updated**--');
// prod.Pieces_in_Pack__c = '1';
// }
// }
//}
Hi Surendra,
Which error ir gives?
Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator & Advanced Administrator & Sales cloud consultant
My Blog:- http://mrjavascript.blogspot.in/
Error: Compile Error: unexpected token: else at line 18 column 9
trigger Compare_OldandNewvalues on Product2 (before update) {
for (Product2 prod: Trigger.new) {
if(prod.Ampics_PL__c !=null && Product.Ampics_PL__c == 'Utilix') {
String str = 'Utilix';
String[] sstr = str.split('/');
system.debug(sstr[0]);
system.debug(sstr[1]);
prod.Ampics_PL__c = 'sstr[1]';
System.debug('--*Product Value is changed*--');
System.debug('**Ampics_PL__c :'+Ampics_PL__c.sstr[0]);
System.debug('**Ampics_PL__c :'+prod.sstr[0]);
}
}
} else {
System.debug('--**Product2 Number has not been Updated**--');
prod.Pieces_in_Pack__c = '1';
}
}
}
Hi,
I have updated your trigger code.
Try to use following code.
Apex Trigger:
Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.
Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator & Advanced Administrator & Sales cloud consultant
My Blog:- http://mrjavascript.blogspot.in/