+ Start a Discussion
Deepak PansariDeepak Pansari 

System.SObjectException: Field Lead.LastViewedDate is inaccessible [ LastViewedDate ]

Hi All,

 

I have a code which are getting all the fields name and their properties like api name, label , data type.

 

Now for deployed the code I am getting this exception :

System.SObjectException: Field Lead.LastViewedDate is inaccessible in this context.

 

It seems that there is a field "LastViewedDate" , I have checked all fields but I am not able to find this.

Please let me know if any one have any idea.

 

Regards,

Deepak

 

AmitSahuAmitSahu
The target org you are deploying might have that field and some test method might be failing on that org.
Deepak PansariDeepak Pansari

Hi , 

 

I have checked again and there is no such field in any org.

 

Is there any way to find out what are the fields are present for Lead object.

 

- Deepak

JitendraJitendra

Hi Deepak,

You can use the force.com IDE (Eclipse) for Schema browsing. You can see all fields there or you can use Dynamic Apex also.

 For Dynamic Apex code snippets refer below article:

http://shivasoft.in/blog/salesforce/very-useful-tips-and-tricks-of-the-apex-salesforce-interview-questions-part-4/

Deepak PansariDeepak Pansari

Hey Jitendra,

 

Thx I used the code mentined in the site , But still unable to find field "LastViewedDate".

 

Any other thoughts?

 

- Deepak

JitendraJitendra

Hi Deepak,

 

If you are not able to see the field then it means it is not present. You will need to create that field.

AmitSahuAmitSahu
Simply check them under leads fields
Deepak PansariDeepak Pansari

HI,

 

I have checked all possibe way to find that field in both org , but not able to find it.

 

If you see my subject line it seems "LastViewedDate" , its standard field.

 

- Deepak

AmitSahuAmitSahu
When exactly you are getting this error ? While deploying ? If yes the there could be some more specific error message .
Laxman RaoLaxman Rao

Change the version of the class to 28.0.

 

LastViewedDate is accessible in summer 13.

You can refer here : https://na14.salesforce.com/help/doc/en/salesforce_summer13_release_notes.pdf

(search for LastViewedDate)

Pavlo Shchur 31Pavlo Shchur 31
Should version be 28 or it could be higer?
Shai FisherShai Fisher
It happen to me when i refreshed a VF page in lightning:
"Field Product2.LastViewedDate is inaccessible in this context".
When i refreshed the page by entering the page again (or entering the url again), and not by reloading, it solved.
This field is not referenced anywhere in my code.