7

I'm trying to create a read-only "enhanced note" and I see that there is a property on ContentNote for IsReadOnly which would work perfectly for the use case but unfortunately:

Line: 1, Column: 17 Field is not writeable: ContentNote.IsReadOnly 

I have been looking into what controls the read-only behavior that might exist on a ContentNote and I cannot identify what influences this attribute for it to return true.

  • What makes an enhanced note read-only?
  • Is there something on ContentDocument or ContentDocumentVersion that might influence it?
2
  • Are you able to find out on this? I am running into same issue where I need to create "Read-Only" notes Commented Mar 28, 2023 at 18:33
  • Unfortunately, I did not locate an answer to this. Commented Mar 28, 2023 at 18:51

1 Answer 1

1

While the IsReadOnly still cannot be set at creation because error Field is not writeable persists, the closest we can get to set the ContentNote to read-only is by setting the ShareType to V on the ContentDocumentLink that links the note to a record.

// First create and insert the note ContentNote note = new ContentNote(); note.Title = 'My Note'; note.Content = Blob.valueOf('This is the note text'); insert note; // Then create the ContentDocumentLink with ShareType = 'V' for viewer permission ContentDocumentLink cdl = new ContentDocumentLink(); cdl.ContentDocumentId = note.Id; cdl.LinkedEntityId = '<recordId>'; // The ID of the record you're sharing to cdl.ShareType = 'V'; // 'V' for Viewer permission makes it read-only cdl.Visibility = 'AllUsers'; // or whatever visibility you need insert cdl; 

One thing that comes up after the above is that another user indeed sees the note as read-only and there's a text that clearly indicates this:

enter image description here

If we write a simple LWC to query and display the IsReadOnly field, viewing the information as another user shows that IsReadOnly = true

ContentDocumentLink documentation

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.