I am trying to get the name of files saved inside a salesforce object. I do this query:
const files = await this.conn.sobject('ContentDocumentLink').find({
LinkedEntityId: documentId,
ShareType: 'V'
})
it provides me with :
{
attributes: {
type: 'ContentDocumentLink',
url: '/services/data/v42.0/sobjects/ContentDocumentLink/xxxxxxxxx'
},
Id: 'xxxxxxxxx',
LinkedEntityId: 'xxxxxxxxxxx',
ContentDocumentId: 'xxxxxxxxxxx',
IsDeleted: false,
SystemModstamp: '2022-02-24T12:03:04.000+0000',
ShareType: 'V',
Visibility: 'AllUsers'
}
But all I have are the unique IDs of each file. I need the file names as well. How do I then query to populate and get the file name as well?
Thank you for your help.
You can try to perform SOQL Query to retrieve the name of the file.
this.conn.query("SELECT contentdocument.title FROM ContentDocumentLink where ContentDocumentId = 'SOME_FILE_ID'", function(err, result) {
if (err) { return console.error(err); }
console.log("result : " + result);
});