0

I have an org with SNotes enabled. I am trying to use REST API to query SNotes on Account. If the current user adds an SNOTE, then a simple SOQL query like so returns it:

GET /services/data/v42.0/query?q=SELECT%20Id,%20IsReadOnly%20FROM%20ContentNote

However, if a note is added by ANOTHER user, the above does not return those.

Nevertheless, if i know the id, i CAN see it using:

GET /services/data/v42.0/query?q=SELECT%20Id,%20IsReadOnly%20FROM%20ContentNote%20WHERE%20Id='0690SOMEIDHERE'

I tried querying the notes using a subquery on ContentDocumentLink:

SELECT Id, IsReadOnly FROM ContentNote WHERE Id IN (
  SELECT ContentDocumentId FROM ContentDocumentLink 
  WHERE ContentDocument.IsArchived = false AND LinkedEntityId IN 
   (SELECT Id FROM Account WHERE Account.OwnerId = 'MyUser' 
   OR Account.Owner.ManagerId = 'MyUser'))

And, unsurprisingly, got back a

Entity 'ContentDocumentLink' is not supported for semi join inner selects

error.

I can see the SNotes through ContentDocumentLink query like so:

SELECT Id, SystemModstamp, ContentDocumentId, LinkedEntityId, ContentDocument.ContentAssetId, ContentDocument.Title, ContentDocument.Description, ContentDocument.FileExtension, ContentDocument.FileType, ContentDocument.ContentSize, ContentDocument.ContentModifiedDate, ContentDocument.OwnerId, ContentDocument.LastModifiedDate FROM ContentDocumentLink WHERE ContentDocument.IsArchived = false AND LinkedEntityId IN (SELECT Id FROM Account WHERE Account.OwnerId = 'MyUser' OR Account.Owner.ManagerId = 'MyUser')

However, the results above do not indicate that the note is read only, so when i try to PATCH it, the query fails.

I need to know whether a group of notes are editable by a current user or not, through the REST API. Since there are potentially thousands of notes, i do not want to run the by Id selects from ContentNote for all of my notes, as the user will run out of API calls as limited by the org.

Any suggestions?

  • Hi are you able to find solution for this.. – Anitha J J Dec 18 '19 at 13:09
  • 1
    @AnithaJJ sort of. I did what i mentioned in my post - i used ContentDocumentLink to pull out notes, and then on top of that i built an Apex rest endpoint which gives me back the IsReadOnly. This is all pretty limited but was the best i can do. – zaitsman Dec 18 '19 at 23:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.