You need to sign in to do that
Don't have an account?
Jive JIF
Querying all notes related to a Contact
Hi,
I'm trying to query all notes related to a contact, displaying these notes with title and textpreview and also order them by date. I also need this to be pageable.
I'm using SOQL. Now, my solution at first was that I select all item from the ContentDocumentLink table which has the contactId I'm working on. With this I could get all ContentDocumentId for this contact (obviously these are not all Notes). The next step would be to query the ContentVersion table where I can use the ContentDocumentIds from the previous step and filter out items where the FileType are not "SNOTE".
However this solution is not really good for what I want to achieve as I still lacks the paging feature. I could use limit/offset with the ContentDocumentLink table but there not every item are Note.
I also try to worl with the ContentNote table directly but I still would need to get it to pair them to the contact so I'm kind of stucked.
Is there a simpler way to achieve this?
Thanks for the answers!
I'm trying to query all notes related to a contact, displaying these notes with title and textpreview and also order them by date. I also need this to be pageable.
I'm using SOQL. Now, my solution at first was that I select all item from the ContentDocumentLink table which has the contactId I'm working on. With this I could get all ContentDocumentId for this contact (obviously these are not all Notes). The next step would be to query the ContentVersion table where I can use the ContentDocumentIds from the previous step and filter out items where the FileType are not "SNOTE".
However this solution is not really good for what I want to achieve as I still lacks the paging feature. I could use limit/offset with the ContentDocumentLink table but there not every item are Note.
I also try to worl with the ContentNote table directly but I still would need to get it to pair them to the contact so I'm kind of stucked.
Is there a simpler way to achieve this?
Thanks for the answers!
You can get the ContentNote details using relationship fields by querying on ContentDocumentLink object and filtering it with LinkedEntityId
Please refer to the below links which might help you further:
https://salesforce.stackexchange.com/questions/263808/how-to-fetch-contentnote-records-as-per-the-contact-record
https://salesforce.stackexchange.com/questions/138727/query-all-content-notes-of-an-opportunity
I hope it helps you.
Regards,
Khan Anas
All Answers
Greetings to you!
You can use the below SOQL to get all the notes related to Contact:
Please refer to the below links which might help you further with the above requirement.
https://medium.com/@krissparks/soql-query-for-notes-on-an-object-a94221f61083
https://salesforce.stackexchange.com/questions/194743/soql-query-to-get-all-the-note-of-a-account
https://salesforce.stackexchange.com/questions/248812/what-is-the-right-way-to-query-all-notes-attachments
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
* You can use the below SOQL to get all the notes related to Contact:
SELECT Id, Parent.Type FROM Note WHERE Parent.Type='Contact'
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com
Thanks for the answers, however I want to query ContentNote-s, not Notes objects, so in my case the provided answers unfortunately won't working. Do you happen to have a solution for that type of objects? Thank you again and have a nice day!
Greetings to you!
I have gone through your query.
Please try below query:
List<Note> Notes_List = [select Id,Parent.Id,Parent.Type from Note where Parent.Type='Contact'];
Please visit the link for detailed explanation:
1. https://medium.com/@krissparks/soql-query-for-notes-on-an-object-a94221f61083
2. https://salesforce.stackexchange.com/questions/248812/what-is-the-right-way-to-query-all-notes-attachments
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com
You can get the ContentNote details using relationship fields by querying on ContentDocumentLink object and filtering it with LinkedEntityId
Please refer to the below links which might help you further:
https://salesforce.stackexchange.com/questions/263808/how-to-fetch-contentnote-records-as-per-the-contact-record
https://salesforce.stackexchange.com/questions/138727/query-all-content-notes-of-an-opportunity
I hope it helps you.
Regards,
Khan Anas
That did the trick thank you very much!
Regards,
Istvan Reiter