-
Notifications
You must be signed in to change notification settings - Fork 238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't aggregate Salesforce Files (ContentDocumentLink) as child object #433
Comments
Thanks for sharing @matthewsouther, i'll flag this as a future enhancement, maybe there is a workaround the platform limitation. |
Are there any updates to this thread? I'm trying to count the number of files for a custom object and run into this if I try to run via Process Builder or Real-Time. When I just run the lookup to calculate from the Manage screen, it runs through and updates. |
I think this is fixed per pull request #585 |
Yes @douglascayers i would agree. |
Fixed in v2.10 |
Hi, Can you please help over it. |
Hi @afawcett, I have tested this with v2.10 and I'm not getting reliable results:
Any clues? Thanks! |
Ok thanks for confirming, i'll re-open since our hope this was fixed via #585 does not seem to have transpired sadly. |
I'm unable to deploy the trigger for the child object ContentDocument, receive the following error: Error: |
Hi @Ltowns, You should use ContentDocumentLink object instead of ContentDocument or ContentVersion objects. One reason is that sharing security is based on ContentDocumentLink object. Users, even admins, only can query and see ContentDocument or ContentVersion records explicitly shared to them. Any whose access is inferred by the user having access to the record the file has been shared to (e.g. account or contact) are ignored. So you would not get accurate counts and the counts would change based on the context user each time. The other reason is that ContentDocument records can’t be inserted or updated directly which is why the auto-generated test fails. The document is created by Salesforce when a ContentVersion record is inserted and its ContentDocumentId field is null. |
Got it, thanks. Then it appears that by using ContentDocumentLink I can't
filter by the Title or FileType. What I'm trying to do is identify if there
is a File attached to an account that contains the title "Account Form" by
getting a count using that as a filter.
…On Tue, Feb 27, 2018 at 5:12 PM, Doug Ayers ***@***.***> wrote:
Hi @Ltowns <https://github.com/ltowns>,
You should use ContentDocumentLink object instead of ContentDocument or
ContentVersion objects.
One reason is that sharing security is based on ContentDocumentLink
object. Users, even admins, only can query and see ContentDocument or
ContentVersion records explicitly shared to them. Any whose access is
inferred by the user having access to the record the file has been shared
to (e.g. account or contact) are ignored. So you would not get accurate
counts and the counts would change based on the context user each time.
The other reason is that ContentDocument records can’t be inserted or
updated directly which is why the auto-generated test fails. The document
is created by Salesforce when a ContentVersion record is inserted and its
ContentDocumentId field is null.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#433 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AjMiNCdW48lhpUrLbP_R6lgcy6J7yPghks5tZKf3gaJpZM4K2rDv>
.
|
You might try cross object filter criteria like “ContentDocument.Title = ‘Account Form’” |
Hello @afawcett, Please, could you let us know if there is an estimated time of resolution for the issue reported by Sebas on the 31st of January? Many thanks! |
@Jesus-GA sadly i cannot give an ETA, this is an open source project and thus dependent on peoples personal time. It is flagged as a priorty issue though, which means when some time from a dev does come up this will be one of those looked at first. |
I'm also finding that the count in Realtime does not go down for linked Files (rollup based on ContentDocumentLink), though it goes up just fine. A Scheduled rollup does result in number going down for deleted files. But for some use cases a scheduled rollup may not meet the need. |
Hi, I was wondering if this has been fixed. I'm working with another client and they could really use DLRS as long as it supports ContentDocumentLink object. Thanks for the hard work! |
This issue where the count of files will correctly count for added files but not for deleted files is still occurring in the latest version (2.13). I noticed that if I select the option for "Remove from Record" then the decrementing on the count does work, but not for a Delete. We need this to be accurate in real time so, unfortunately, a scheduled run to correct any incorrect counts won't work. I would love to understand why the behavior on this object is different from other Salesforce objects. |
Hi, I have setup the roll-up based on ContentDocumentLink and created the trigger successfully. However, when I tested by upload a new file to the record, it throw me an error - "Can't add 1 file to Opportunity" I read through the Salesforce Help & Training and it ask to inactive the ContentDocumentLink trigger (https://help.salesforce.com/s/articleView?id=000313353&type=1) . Please advice how or any althernative way I could create the roll-up to calculate the number of attachment / files on the object? |
@JobbyC, are you able to collect any logging information for what is happening? Maybe use Salesforce Debug Logs and send us what you find there? Unfortunately that error message doesn't include any details. Can you also include the details of your rollup so we can understand how you have it configured? Completely random guess but I'd suggest one of two likely scenarios. Something in the rollup is configured incorrectly which is throwing an error or something about your opportunities is rejecting this record edit to save the rollup value, maybe a validation rule or something similar. For future reference I'll do what I can here but I recommend you check into the Trailhead community group here, https://trailhead.salesforce.com/trailblazer-community/groups/0F9300000009O5pCAE. You're much more likely to get help and support there. Thanks! |
Hi, Has the issue been fixed to reduce file count when a file is deleted? Are there any workarounds to address this? |
@SF-Q Yes managed to resolve it. I attached the roll-up that I did here, hope this help :) |
@JobbyC - I have the same configuration and the file count does not decrease when I delete files. Did you have to write additional code? |
@SF-Q If you use the delete option, it will not decrease the number. So, need to click the last option "Removed from Record" and the recalculation will work. |
@riekusr I don't think this issue ticket would be the correct place to discuss your issue. Please reach out on the Trailblazer Community Group (https://trailhead.salesforce.com/trailblazer-community/groups/0F9300000009O5pCAE) and we can discuss it there. Thanks! |
Due to an apparent SOQL limitation with the ContentDocumentLink standard object, attempts to use DLRS to capture the ID of the most recent file on a parent record fail.
The validation error reads:
"Apex trigger dlrs_ContentDocumentLinkTrigger caused an unexpected exception, contact your administrator: dlrs_ContentDocumentLinkTrigger: execution of AfterInsert caused by: System.QueryException: Implementation restriction: ContentDocumentLink requires a filter by a single Id on ContentDocumentId or LinkedEntityId using the equals operator or multiple Id's using the IN operator.: Class.dlrs.LREngine.QueryExecutor.query: line 631, column 1"
See Success Community thread: https://success.salesforce.com/0D53A00002v7xXO
The text was updated successfully, but these errors were encountered: