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
Gauri Gaikwad 13Gauri Gaikwad 13 

datatype error in apex class

hi, i am trying to add trigger  & apex code i am getting error as (Error: Compile Error: Invalid type: Pen_c at line 3 column 51).


code in apex class----------------------

Public Class PenClassDemonstration{

public static void ApplyDiscountPen (List< Pen_c >VarPensListNew){

For(Pen_c VarP: VarPensListNew){

if(VarP.Price_c>= 100){

VarP.Price_c= VarP.Price_c- 20;

}
}
}
}
 
Best Answer chosen by Gauri Gaikwad 13
AnkaiahAnkaiah (Salesforce Developers) 
Also, check the object Pen__c  is available in your org or not.

All Answers

AnkaiahAnkaiah (Salesforce Developers) 
API Name incorrect. from Pen_c to Pen__c

try with below code.

 
Public Class PenClassDemonstration{

public static void ApplyDiscountPen (List< Pen__c > VarPensListNew){

For(Pen__c VarP: VarPensListNew){

if(VarP.Price__c>= 100){

VarP.Price__c= VarP.Price__c- 20;

}
}
}
}

If this helps, Please mark it as best answer.

Thanks!!





 
Gauri Gaikwad 13Gauri Gaikwad 13
It is still showing error with this code

Error: Compile Error: Invalid type: Pen__c at line 3 column 53
AnkaiahAnkaiah (Salesforce Developers) 
Hi Gauri,

Can you share the apex trigger code?
AnkaiahAnkaiah (Salesforce Developers) 
Also, check the object Pen__c  is available in your org or not.
This was selected as the best answer
Gauri Gaikwad 13Gauri Gaikwad 13
yes object is present with api name Parker_Pen__c
 
Gauri Gaikwad 13Gauri Gaikwad 13
trigger code

trigger PropertyDiscountTrigger on Property_c(before update) {

PropertyClassDemonstration.ApplyDiscountProperty(Trigger.New);
}
Gauri Gaikwad 13Gauri Gaikwad 13
hey hi , it is solved , i was using wrong API name in apex class & in trigger code also. parker_Pen_c was the wring API name

Thank you so much 
 
Gauri Gaikwad 13Gauri Gaikwad 13
Thank you for the clarification. It worked.