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
anusha edpuganti 2anusha edpuganti 2 

I wrote apexclass for insert note into custom object, i am trying to save that it is showing Error: Compile Error: Variable does not exist: ParentId at line 163 column 19 .please help me any one, why it is occur

Error: Compile Error: Variable does not exist: ParentId at line 163 column 19
global with sharing class RelatedList{
@RemoteAction
    global static String insert_Note_Row()
     {
         Note n = new Note();
               try {               
                n.ParentId='a017F0000015hib';
                n.Body='she is ok';
                n.Title='New Note';
                insert n;
            } catch (DmlException e) {
            }            
        return('insert note successfull');                           
     }            
}
Waqar Hussain SFWaqar Hussain SF
Sometimes this error shows due to versioning issue. copy and past the below code in developer console. If it runs from developer console. 

Then update you api version of the class, this will probably solve your problem.
 
Note n = new Note();
try {               
    n.ParentId='a017F0000015hib';
    n.Body='she is ok';
    n.Title='New Note';
    insert n;
} catch (DmlException e) {
    system.debug(e.getmessage());
}

FYI: Prent is ID of the object associated with the note.​

On which object you are creating note. May the object does not support notes.
om gupta(sfdc)om gupta(sfdc)
i think your code is correct . may be issue in 'a017F0000015hib' plz check with  account id to test . if that ok then may be the id which you have assigned not given permission. by the way this id belong to which object
anusha edpuganti 2anusha edpuganti 2
hi @ Waqar,
Still same error in developer console
Waqar Hussain SFWaqar Hussain SF
Hi,
Every Org has its own prefix for sObject except standard object. So we can't identify custom object by prefix. 

I tested for Account and is working fine for me. 
Waqar Hussain SFWaqar Hussain SF
copy and paste of an account account on parent Id 
 Or check below code in developer console.
Note n = new Note();
try {               
Account acc = [Select Id from account limit 1];    
n.ParentId=acc.Id;
    n.Body='she is ok';
    n.Title='New Note';
    insert n;
} catch (DmlException e) {
    system.debug(e.getmessage());
}

 
Asif Ali MAsif Ali M
Are you sure the that the below line is triggering the issue? It is on line line 163?
n.ParentId='a017F0000015hib';
Try deleting the APEX file and add it again.