You need to sign in to do that
Don't have an account?
Trying to resolve error - Variable does not exist: Id
I have been trying to find out what's wrong with some apex code. I started seeing compile errors, so I reduced the code to the most basic code to try to find the issue, but I'm not sure what I'm doing wrong here.
Here's the stripped down version of my code:
public with sharing class ContactTriggerHandler {
public static void UpdateOptLogs(List<Contact> newContacts) {
//Read the new values of the Contact object
for (Contact contactObj: newContacts)
{
system.debug(' contactObj.Id : ' + contactObj.Id);
}
}
}
I get an error : Result: [OPERATION FAILED]: ContactTriggerHandler: Variable does not exist: Id (Line: 6, Column: -1)
Thanks for your help.
Here's the stripped down version of my code:
public with sharing class ContactTriggerHandler {
public static void UpdateOptLogs(List<Contact> newContacts) {
//Read the new values of the Contact object
for (Contact contactObj: newContacts)
{
system.debug(' contactObj.Id : ' + contactObj.Id);
}
}
}
I get an error : Result: [OPERATION FAILED]: ContactTriggerHandler: Variable does not exist: Id (Line: 6, Column: -1)
Thanks for your help.
if it is exist please rename the class.
All Answers
if it is exist please rename the class.
public void UpdateOptLogs(List<Contact> newContacts) {
...
@Abu, I am getting the error on the code that I posted in the initial post.
@JeffreyStevens, I have other existing handler classes in the same org that are static. These compiled successfully and are deployed to the production org. I will change this class to a non-static class and try it out to eliminate this possibility.
public void UpdateOptLogs(List<Contact> newContacts) {
Otherwise, try lastname and see if it works or not (if not then it's the object, if it works then it's the field)
As a common practice, if your question is answered, please choose 1 best answer.
But you can give every answer a thumb up if that answer is helpful to you.
Thanks
Thx