You need to sign in to do that
Don't have an account?

Querying ContentDocument Through System Log API Vs Apex Class
Hi All,
I've run into an issue where I am able to return results from the ContentDocument object using the system log API but no results are returned from the exact same query I have written in my apex class. Anyone know of any restrictions or ways around this issue?
I finally figured it out. The apex class I built was api version 20.0. I set it to 23.0 and I can now retrieve the id.
All Answers
Hi,
I understand that you are using apex class to return content, may i know where are you displaying it ( i mean site, portal or etc.,.). I am sure it is related to permission issues.
Thanks.
I am trying to display the Id of a ContentDocument on a visualforce. The query that throwing an error returning no rows in the apex class is the following.
Id ParentId = [Select Id from ContentDocument where Title like 'Monitor1%' LIMIT 1].Id;
I as an administrator am the one viewing this visualforce page, and it still retrieves 0 rows and throws the exception. Running this exact query copied and pasted into the system log api I retrieve 1 row.
Hi,
What is that exception message?
I assume you have content permissions enabled in your user record.
Also, navigate to respective workspace and give yourselves workspace admin permission for time being and then try your apex class.
Thanks.
I cant return any contentdocuments through an apex class. Try the following in an apex class and visualforce page.
public class with sharing ContentController{
public string getdocumentid(){
string documentid = [Select Id from ContentDocument LIMIT 1].Id;
return documentid;
}
}
-----------------------
visualforce page
-----------------------
<apex:page controller="ContentController">
<apex:form>
{!documentid}
</apex:form>
</apex:page>
You will get the list exception error for returning no rows.
Hi,
This works for me,
Thanks.
I finally figured it out. The apex class I built was api version 20.0. I set it to 23.0 and I can now retrieve the id.