You need to sign in to do that
Don't have an account?

Error in product trigger
Error: Compile Error: Entity 'Product' not accessible in version 29.0 at line 1 column 1 please help me thanks in advance
trigger updateNewvalues 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]);
System.debug('--*Product Value is changed*--');
System.debug('**Ampics_PL__c :'+prod.sstr[0]);
}
else{
prod.Pieces_in_Pack__c = '1';
}
}
}
prod.Pieces_in_Pack__c = '1'; In this line,
update it to
prod.Pieces_in_Pack__c = 1;
Or
prod.Pieces_in_Pack__c = (Deicmal)1;
Or
prod.Pieces_in_Pack__c = Deicmal.valueOf(1);
All Answers
Hi surendra,
You have to update your trigger code. in trigger try to use prod. instead of Product.
see below updated trigger 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/
@surendra123
In this line :
if(prod.Ampics_PL__c !=null && Product.Ampics_PL__c == 'Utilix') {
Change Product.Ampics_PL__c to prod.Ampics_PL__c
Error: Compile Error: Invalid field sstr for SObject Product2 at line 9 column 46
@Surendra123,
System.debug('**Ampics_PL__c :'+prod.sstr[0]);
Remove prod in this line. sstr is a string that you created in previous steps. its not product's field.
Error: Compile Error: Illegal assignment from String to Decimal at line 11 column 13
trigger updateNewvalues on product2 (before update) {
for (Product2 prod: Trigger.new) {
if(prod.Ampics_PL__c !=null && prod.Ampics_PL__c == 'Utilix') {
String str = 'Utilix';
String[] sstr = str.split('/');
system.debug(sstr[0]);
system.debug(sstr[1]);
System.debug('--*Product Value is changed*--');
System.debug('**Ampics_PL__c :'+sstr[0]);
}else{
prod.Pieces_in_Pack__c = '1';
}
}
}
What is the data type of Pieces_in_Pack__c field in product?
Deepa,
Its number The datatype for Pieces_in_Pack__c is a number
prod.Pieces_in_Pack__c = '1'; In this line,
update it to
prod.Pieces_in_Pack__c = 1;
Or
prod.Pieces_in_Pack__c = (Deicmal)1;
Or
prod.Pieces_in_Pack__c = Deicmal.valueOf(1);
if i give any value in the product description such as Management/123
i need to update /123 in the Pieces_in_Pack__c = '1';
Deepa,
if there is any value in the product description as mananagement/2345 we need to place the 2345 in the piece of packs if there is no value it must default to 1
You can check for numeric in the string and parse accordingly. If it contains blank value then assign '1' to it.