Skip to content
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

Error When Adding a Note in SF Lightning Due to DLRS Trigger #558

Closed
ccharles76 opened this issue Sep 7, 2017 · 5 comments
Closed

Error When Adding a Note in SF Lightning Due to DLRS Trigger #558

ccharles76 opened this issue Sep 7, 2017 · 5 comments

Comments

@ccharles76
Copy link

I need to track employee/consultant expenses and have a custom object in Salesforce Enterprise Edition called “Expenses”. We need to be able to see if there are attachments (receipts) to those expenses. We are using the Lightning interface, so we had to use the new Salesforce Files/Notes object instead of the traditional Attachments related list. Because there is not a master-detail relationship between expenses and Files, we were unable to do a roll-up summary and thus I used the Declarative Rollup Lookup Summary tool to create a rollup summary (see attached screen shot of the setup).

It is calculating the number of “Files” correctly and I thought all was well. However, I recently learned that the trigger that the DRLS created causes an issue with the “Files” / “Notes” object. In Lightning or Classic, if I attempt to create a new Note in Salesforce, I receive an error. The error is more descriptive in Classic and the error says:

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 659, column 1

Does anyone have a suggestion as to how to solve this issue? Thank you, in advance!

dlrs setup
dlrs trigger

@ccharles76
Copy link
Author

Sorry that I'm new to this, but has anyone experienced this issue before or know how to overcome it? Thank you!

@aheber
Copy link
Contributor

aheber commented Sep 18, 2017

@ccharles76 I haven't used DLRS for this object before. The error is strange indeed. I'll make some time this week to try this out. If I can get the same error then we can work on a resolution.

I'll respond back at some point this week.

@ccharles76
Copy link
Author

ccharles76 commented Sep 19, 2017

I was able to find a work-around, but it doesn't work as well as I would like. I wanted to share it:
There is a small issue with my work-around that I could use some advise on. I removed the trigger and revised the DLRS record by adding a Lookup Rollup Summary Unique Name and changing the Calculation Mode to Process Builder (as shown in the file attachment; Revised DLRS Setup).

revised dlrs setup

I was able to create a Process Builder rule based on my Expense Object when the Amount field Is Changed = TRUE OR Amount Is Null = FALSE. The Immediate Action is to call APEX, referencing my rollup summary unique name and the Parent Record Id of my Expense.Id field.

pbuilder-amountchanged
pbuilder-action-callapex

It runs correctly after I make an edit to the Expense record, but if I just add a File (attachment), the process builder does not trigger.
Any suggested way to get the Process to fire upon uploading of a File to the expense record?

afawcett added a commit that referenced this issue Nov 25, 2017
…dding-note

Fixes issue #558 by avoiding running query that won't have any masterRecordIds to filter by
@afawcett
Copy link
Collaborator

I have now merged @douglascayers fix, it will go out in the next package release.

@afawcett
Copy link
Collaborator

afawcett commented Jan 1, 2018

Fixed in v2.10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants