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
Nagraj Naik 4Nagraj Naik 4 

Compile Error: Invalid type: Pen__c at line 3 column 58


public Class PenClassDemonstration {
        public static void ApplyDiscountPen(list<Pen__c> VarPenListNew) {
            for(Pen__c VarP : VarPenListNew){
           if(VarP.Price__c >= 100){
               VarP.Price__c = VarP.Price__c-20;
               }
              }
             }
             }
mukesh guptamukesh gupta
Hi Nagraj,

Please use below code
public Class PenClassDemonstration {
        public static void ApplyDiscountPen(list<Pen__c> VarPenListNew) {
            for(Pen__c penOb: VarPenListNew){
           if(penOb.Price__c >= 100){
               penOb.Price__c = penOb.Price__c-20;
               }
              }
             }
             }

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh
charchit nirayanwalcharchit nirayanwal
It's already correct maybe some other issues
Mukesh you just changed the variable name I don't this is the right solution.
Nagraj checks for the object correct field name and object name.
ravi soniravi soni
hi Nagraj,
your code is looking good. you can refresh the dev console again and just try to reSave and make sure your objectApiName or FieldName And field type are correct.
let me know about your solution if my solution is helpful to you then mark it as best answer.
Thank you
Suraj Tripathi 47Suraj Tripathi 47
Hii Nagraj Naik,

1.Please refresh your dev console resave your code.
2.Change your variables name.
3.Check objName and feild name.

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Suraj
ravi soniravi soni
hi Nagraj,
did you try above solution if it helps then mark it as best answer so that it could be help to others.
thank you