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
SurekaSureka 

How to display "Object Name" in Visualforce?

Hi All,

 

I m querying the NotesAndAttachments using this query, "Select Id, IsNote, Parent.Type,Parent.Name, Title, OwnerId, CreatedDate, CreatedById,  CreatedBy.Name,LastModifiedDate, LastModifiedById From NotesAndAttachments". I am trying to display Parent.Type in the visualforce. I encountered the below error:

 

Validation Errors While Saving Record(s) There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Type: value not of required type: Project Information(db=a0Z,api=RIT_ProjectInformation__c)".

 

Any Suggestions?

 

Thanks

 

Jon Mountjoy_Jon Mountjoy_

There are two problems, and I can only solve one:

 - The object is called NoteAndAttachment, not NotesAndAttachments ;-)

 

The other is that you can't query the object directly (so even if you spell it correct, it still won't work)

 

As the docs say: 

To retrieve this object, issue a describe call on an object, which will return a query result for each activity since the object was created. You cannot use query().

 

LMK how you solve this :-)

 

Jon

SurekaSureka

Hi Jon,

 

Thanks for your reply.

 

I am querying Notes & Attachments using this query,

 

"Account a = [select Id, (select Id,Parent.Type from NotesAndAttachments) from Account limit 1];"

 

ie,.using inner query.

 

Thanks

Bhuvana

Pradeep_NavatarPradeep_Navatar

NoteAndAttachment object does not support query. So You cannot get parent id from NoteAndAttchment object. Try running a query on Attachment object instead.

SurekaSureka

Hi,

 

I am able to retrieve NotesAndAttachments with the help of the above query and I am able to display the list in VF page.That's not the problem.

 

When I am tring to display "Parent.Type" in VF page, I m getting the below error:

 

Validation Errors While Saving Record(s) There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Type: value not of required type: Project Information(db=a0Z,api=RIT_ProjectInformation__c)".

 

Thanks