Git Product home page Git Product logo

sfdc-related-files-lightning's Introduction

View Salesforce Files of Related Records

See files shared to all related records on one page in Lightning.

This project provides a Lightning Component you can drag on to your Lightning Record Pages in App Builder.

screen shot

Background

As of Summer '17 release, Lightning Files related list behaves fundamentally different than Classic Notes & Attachments related list when it comes to showing files and attachments shared to not only to the current record but also shared to related child records.

When viewing the Classic Notes & Attachments related list on an account, for example, attachments belonging to the account and its related contacts, cases, opportunities, tasks, etc. are displayed in one combined list.

When viewing the Lightning Files related list on the same account, for example, only the files explicitly shared to the account are displayed. The files shared to its related contacts, cases, opportunities, tasks, etc. are not displayed in the same combined list.

This is a known limitation and by design according to this help article.

Community Requests

However, this "rollup" of Classic Attachments is a much beloved feature and customers are asking for it in Lightning Experience.

Keri-An Richards took to the IdeaExchange and submitted Roll up display of Notes and Attachments in Lightning as it was in Classic.

screen shot

Others, like Abi Beaty and Hilary Henderson, have also inquired on the Success Community how to get this rollup feature in Lightning.

screen shot

screen shot

Seeing a need I began developing this app. After sharing a sneak peek on Twitter, Haris Ikram, Product Manager for Salesforce, commented that such a solution is in demand and happy to share this with the Salesforce Lightning Team.

screen shot


Packaged Release History

Release 1.3 (current release)

Installing the Source Code (Developers)

You may install the source code from GitHub and make any desired adjustments. You are responsible for ensuring unit tests meet your org's validation rules and other requirements.


Getting Started

  1. Setup My Domain. My Domain is required to use Lightning Components. (Trailhead Module)

  2. Add the Files related list to your Page Layouts (Trailhead Module)

  3. Add the Related Files custom Lightning Component to your Lightning Record Pages (Trailhead Module)

Check out this 7 minute setup and how-to video:

screen shot

Recommendations

  • This component only works with Lightning Files, if you are still using Classic Attachments then I recommend that you migrate them.
  • Add a new tab on your Record Pages labeled "Files" then add the standard Related List component (configured to show the Files related list) and my custom Related Files component.

FAQ

If one of your questions isn't answered below, please search and comment on existing issues before opening a new one. Thanks!

Which files are shown in the Lightning Component?

Files shared to child records that the user has access to. A child record is any record found in one of the related lists of the main record being viewed. For example, if viewing an account then the component could show you all files shared to contacts, cases, opportunities, etc. belonging to that account.

Specifically when viewing an account, files related to tasks and events that are related to child records of an account do rollup and are visible at the account level. This is possible because of the standard Task.AccountId and Event.AccountId fields and Salesforce populating them for account rollup behaviors.

As a System Administrator, you may customize which related lists are visible in this component. By default, all relationships accessible by the current user are displayed in the vertical navigation.

How do I customize which related lists are shown in the vertical navigation?

In App Builder when editing the Record Page you added the Related Files lightning component, there is a customization attribute named Child Relationships. Enter a comma-delimited list of the API name(s) of the child relationships as defined on the lookup field on the child object.

For example, if on the Account page you wanted this component to show only files for Contacts and a custom object Invoice__c, you might enter "Contacts,Invoices__r".

To determine a child relationship name, in Setup use Object Manager to navigate to your child object (e.g. Contact or Invoice__c) then navigate to the lookup field that points to the parent object (that is the object whose Lightning Record Page you're adding this component). On the field's detail page you'll see the field label, field name, and the child relationship name (use this value in App Bulider). If this is a custom lookup or master-detail field then you will need to append __r to the child relationship name.

screen shot

What do the badge counts mean in the vertical navigation?

The badge count is the number of unique files shared to those related records.

For example, if the single file "Hello.txt" is shared to 3 contacts related to the same account then when viewing this Related Files lightning component on that account page would display the badge count 1 for the Contacts relationship even though 3 contacts exist because only 1 unique file was shared among them.

screen shot

How do I use this app in Classic?

Add the provided buttons labeled View Related Files to your page layouts, or create your own custom buttons that link to /apex/CF_ChildFilesPage?id={!YourObject.Id}.

The Visualforce page supports these URL parameters to customize the component:

Parameters Examples Required? Default
id 15 or 18 character sobject record id yes
r To customize which related lists are shown in the vertical navigation then specify a comma-separated list of the API name(s) of the child relationships whose files to show. no blank, shows all child relationships
f To filter if Files and/or Enhanced Notes are displayed in the lists then specify FILES_ONLY, NOTES_ONLY, or FILES_AND_NOTES no FILES_AND_NOTES

Example:

  • /apex/CF_ChildFilesPage?id=0011I00000345FD&r=Contacts,Invoices__r&f=FILES_ONLY

I don't see Attachments from related records like in Classic, what gives?

This component only works with Lightning Files, if you are still using Classic Attachments then I recommend that you migrate them.

Why is a child relationship name listed multiple times in the vertical navigation?

See issue Use Actual Related List Labels.

Why do the child relationship labels in the vertical navigation not match the labels of the related lists on the page layout?

See issue Use Actual Related List Labels.


Disclaimer

I have only tested this in a Developer Edition org with a few hundred related records and files off one account. If you have a much larger org with thousands of related records and files, please let me know how performance is so I can make any adjustments if needed. Thanks!

Credits

Doug Ayers develops and maintains the project.

License

The source code is licensed under the BSD 3-Clause License

sfdc-related-files-lightning's People

Contributors

douglascayers avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sfdc-related-files-lightning's Issues

2 classes missing in package.xml

Summary

Package.xml in SRC directory misses 2 files

Version of Related Files Lightning Component

1.3

Steps To Reproduce

deploy with FMT / ANT fails.

Package.xml in SRC directory in missing to list these 2 files:

    <members>CF_ChildFilesFieldSetDynamicPicklist</members>
    <members>CF_ChildFilesFieldSetDynamicPicklistTest</members>

easy fix.

Expected Behavior

Deployment succeeds

Actual Result

Deployment failed

Not loading in Production

Hi Doug! I installed this in both my Sandbox and Production instances yesterday and the latter is not working today - it just keeps spinning on load. It is still working in the Sandbox however. Any ideas or troubleshooting steps?

Thank you!

Error when using Field Set

Summary

In version 1.2, the component does not load when trying to use the new field set option.

Version of Related Files Lightning Component

Release 1.2

Steps To Reproduce

  1. Create a field set for ContentVersion object.
  2. In App Builder, add the Related Files component to the lightning record page.
  3. Configure the properties for the component to use the field set from step 1.
  4. The component fails to load any data.

Expected Behavior

The component should load and displays the columns as defined in the field set.

Actual Result

Component fails to load.

System.TypeException: Collection store exception putting Boolean into Map<String,String>

Child Related Object a User Has No Access To

Hi Doug. First off, thank you for this component. I downloaded the code and, in testing, discovered that, if a user does not have any access to one or more of the specified list of child objects (in my case, Opportunity), an error occurs during object initialization. I am specifying a list of objects in the configuration of the component in App Builder. I know the list is correct because it works fine when a user who has at least read access to all specified related objects runs it. I made a fix to the client controller and was wondering if you would be interested in it.

Also, your code made a great starting point for a similar component I made that handles both files and attachments. My client is starting a prolonged rollout of lightning, and we will have a period of time where we will have both attachments and files in the system, until everyone is off of Salesforce for Outlook and we convert all attachments to files with Magic Mover.

Many thanks,

tom

File opens in new browser tab

Doug, first of all, this is a beautiful component.
I am working in console mode. Whenever I click the attachment links, the link opens in a new browser tab. Expected behaviour would be to open a new console tab.

What I would ultimately request is the ability to open a preview link of the file.

I tried to create a new ContentVersion formula field with a hyperlink formula and added this field to the displayed fieldset. However the output of the formula (a href tag) is displayed in the component as text and not as a hyperlink.
Any remarks?

Opportunities not working on Contacts

Hi Douglas,
First of all a big big thank you for this great solution. I just installed the related files component and on the account everything is working as expected - I only want the files for cases, opportunities and contacts showing up and it works. I tried to add the component to the contact object and experience the following issue: When I don't define any specific child relationship, then opportunities files are showing. However, as soon as I specify the child relationship to opportunities its not working and I get the following error:
"Sorry, error initializing component"- what I'm missing here?

Thank you in advance for your help!

Best regards,
Benjamin

Post Winter'21 release, error "You do not have access to the Apex class named :CF_ChildFilesController "

Summary

Post Winter'21 release, the apex classes won't inherit access from lightning components. The access must be granted explicitly.
Users are running into below error while trying to access the related files:
"You do not have access to the Apex class named :CF_ChildFilesController "

Version of Related Files Lightning Component

1.3

Steps To Reproduce

Navigate to the related files section on the account as a user.

Expected Behavior

The related files component loads and displays results

Actual Result

"You do not have access to the Apex class named :CF_ChildFilesController "
image (1)

Include Attachments

Based on feedback from users such as #17, opening enhancement request to support including Attachments.

The original design only queries the ContentDocumentLink object which displays Files (ContentVersion) and Notes (ContentNote).

Ideally, customers would migrate their attachments to files.

Download related files

Doug, it would be nice to download the file directly from the Related Files list. We're required to provide files to field personnel who cannot access internet. We typically download the files to a flash drive for use. I could redirect my users to the related record, but would love the convenience of downloading directly from the related list. A bulk download option would be great as well.

Thanks for an excellent component!

Unable to display custom object in Child Relationships

Awesome component Doug! I don't know if my issue is a bug or just "operator error" but I'm not able to display a custom object in the Child Relationships list. I installed your component and added to the Account page layout. My object name is Fund__c and it has a field called ExternalManager__c that is a lookup to Account. The relationship name is FundToAccount... but when I add FundToAccount to the comma separated list in Child Relationships, the component errors out when I load the Account page.

Thanks in advance for any suggestions!
Steve

<fields> <fullName>ExternalManager__c</fullName> <deleteConstraint>SetNull</deleteConstraint> <externalId>false</externalId> <label>Account Name</label> <referenceTo>Account</referenceTo> <relationshipLabel>Funds</relationshipLabel> <relationshipName>FundToAccount</relationshipName> <required>false</required> <trackHistory>true</trackHistory> <trackTrending>false</trackTrending> <type>Lookup</type> </fields>

Showing Local Record Files

Hi,

I was wondering how to show the files for the current record you are on, I use this app for showing all files in any Service appointment under the work order, this works great but id love it if I could show both service appointment files and work order but when I enter work order under Child relationships it doesn't show. I know this isn't a child relation but when no filters are in this field it does show so they must be a way?

Thank you.

Error with Activities related list from custom lookup field

Hi,

I'm trying to use your solution, with custom object (Company__c).
The company object have related list of activities (On Task I have custom lookup field to Company__c).

But, I don't have the option to put Activities__r (Child relationship name) in the component..

screen shot 2017-08-28 at 12 37 47 pm

Any suggestions?

Thanks, Lee.

Related Files is rolling up on all the tabs

Hi,

I have noticed that when I am using related files related list on the Files tab it is rolling to other tabs as well example News tab.

Version of Related Files Lightning Component

1.3

Steps To Reproduce

On the accounts record page layout, when I have related files component on the
Files tab, that related files tab is rolling to Details and Other tabs as well.

I have attached screenshots. Please help us to resolve this issue asap, as we have rolled this solution to production and users are facing some issues.
Error tab
Related files- expected

Expected Behavior

Earlier it was there in related files tab only. I don't know why it is now there in all other tabs.

Thanks in Advance. Looking forward to hearing from you.

Question: Can your component be used in Classic ?

Can they be used in Visualforce pages with Lightning Out?
I don't know much about how that works, but am looking for a solution for our users which we have not migrated to lightning.

Thanks for all your great work!

Anne-Marie

Sorry, Error Initializing component.

Summary

We have added the related file components on account object in the lightning record page we have a separate tab Files, Notes & Attachments where we have included the related files component. One of our user reported a issue for one account where he/she is seeing the error message 'Sorry, Error Initializing component.'
We have tried to debug it but it is occurring for one of the account record only. We have also checked the apex classes access and also checked the child object access for the user. Those all looks fine for us.
I have attached the screenshot of the error for more details. Could we have get some help here.

Version of Related Files Lightning Component

Version 1.1

Steps To Reproduce

  1. Go to the any Account object.
  2. Go to the File , Notes and Attachments related tab.
  3. You can see the error there.

Expected Behavior

MicrosoftTeams-image (16)

MicrosoftTeams-image (15)

Actual Result

We like to eliminate the error and we would like to know what causing the issue. Could you please help us out on this one.

Lookup relation vs Master-Detail

Hi Doug,

Here are some screenshots of the scenario I described in my last comment. As I mentioned, I am able to successfully add standard objects to the "Child Relationships" section of the Lightning page builder (for the Account object). I was also able to get one object with a lookup relationship to the account added to the Related Files -- hooray!

However, I am still having trouble adding other objects with lookup relationships to the account.

The object is called Partner Deal Registration. It has a lookup field to the Account called "Account Name". I attempted to use the Child Relationship Name (Partner_Deal_Registrations) to pull the Files into the Lightning component.

PDR1

I modified is to "Partner_Deal_Registrations__r", adding in the __r as you suggested, as otherwise I got an error when loading the component.

PDR2

Now the object loads on the component with a count of files (it says 0) but it does not show the files that are actually attached. I attempted modifying the name (removing the "s" from registrations, using _r instead of __r, etc.) but that caused the component not to load properly.

PDR3

As you can see, my other custom object (RFP Support Request) is working perfectly, and I used the same process (child relationship name + __r). Here is a picture of the partner deal registration record that has the attachment on the standard Files related list:

PDR4

Any thoughts on what I may be doing wrong here? I really appreciate your help, this app will be so helpful to my org!!

Thanks,
Alexis

Error Initializing Component - dca_junto_files:Too many callouts: 101

Summary

Hi Douglas, thanks for putting in the effort of making this much-needed component! Our org is quite large so I think that is why we are getting this error:
#Sorry, error initializing component
dca_junto_files:Too many callouts: 101

Version of Related Files Lightning Component

We used the direct link you provided for the Sandbox version as of today (Feb 22, 2021) and installed it for Admins only (which is me).

Steps To Reproduce

  1. Installed Package for Admins only using the link from the README you provided
    Screen Shot 2021-02-22 at 5 10 26 PM
  2. Followed your video exactly, but when I dropped the component into the app builder space, I get this:
    Screen Shot 2021-02-22 at 5 11 42 PM
  3. That's as far as I've gotten, sadly

I should note that the error message I get comes once I've added the component to the page like you did in your video, saved it, and gone back to the front end. After about 10 seconds, this appears:
Screen Shot 2021-02-22 at 4 39 38 PM

Expected Behavior

Default list of child objects should have appeared as in your video. I'm doing this on the standard Account object.

Actual Result

I get this for the component:
Screen Shot 2021-02-22 at 5 14 35 PM

And I get this on the front end when I try to load the page:
Screen Shot 2021-02-22 at 4 39 38 PM

Possible to add more columns and change sorting?

Hi Doug,
Thanks so much for this tool, really a lifesaver for some of my clients.
Is it possible (or on the roadmap) to add the ability to add more columns in addition to the defaults (Title, Owner, Last Modified, Size)?
Similarly, it seems like the sorting is by Last Modified. Is it possible to sort the list by a different column?
Thanks again,
Jon LaRosa

Problems getting this to work in Classic.

Hey there,

I'm towards the end of migrating to Lightning. I converted all of our Files/Attachments only to have complaints about them not rolling up on the Account level as before. I installed your tool in our Sandbox and it works great in Lightning. However, I can't get it to work in Classic. I'm getting "Page CF_ChildFilesPage does not exist" but I don't think I missed any steps here?

Page CF_ChildFilesPage does not exist

1 - Version Installed 1.3
2 - Followed setup video, added Opportunities, Contacts as the "Child Objects" on the Account page setup. Works as expected in lightning
3 - Add "View Related files" on Account page. Click Button and receive the following error, "Page CF_ChildFilesPage does not exist".

I've checked permissions, all profiles have access to this visualforce page. If I click on "preview" of the actual page I see the followig:

Set Up in lightning:
Screen Shot 2019-09-09 at 3 44 24 PM

image

image

Add Support for Professional / Group Edition

Hello. I'm an experienced software engineer but Salesforce n00b, and I could use some help installing this component in our Salesforce org.

I tried using the Deploy From GitHub link, but I receive the following error:

We can't authorize you because of an OAuth error. For more information, contact your Salesforce administrator.

1800 : There was a problem in setting up your remote access

I am the Salesforce admin. I then attempted to manually install this but didn't see how I could add my own custom Lightning component. I'm on Salesforce Professional, not Enterprise. Is installation of custom components like this limited to Enterprise accounts?

Thanks for the great work on this module.

Field bar overlaps component frame

Hi Doug,

Installed this component today, it's great and very helpful, however I noticed a display issue, though I'm not sure if it's just me, where the fields bar overlaps the component frame, I have attached a screenshot.

Kind Regards,
Dylan

overlap

Fatal Component Error

Hello @douglascayers
Setup:
I have the Related Files component included on the Account page layout
Component is configured to display the Email child relationship
Enhanced Email is enabled for the org
I am using Lightning for Outlook to upload email attachments from Outlook to an Account record

Repro:
From the Lightning for Outlook side panel, upload an email with attachments to an Account.

  • Email is attached to Account as a completed activity and File is correctly related to Activity
  • Email category on Related Files component correctly displays the list of uploaded files
  • Clicking on any of the uploaded File names throws a fatal Component Error message with the attached details
    relatedfiles_emailmessagelisting
    relatedfiles_componenterror
    RelatedFiles_ComponentStackTrace.txt

Files related to the Account

Hi,

We have a requirement where users want an holistic view of the related files not just the Child objects but also the files related to the Account. So that all the information is on the same view or section.

Could you please help us if there us any way possible to add this in the current page setup.

Cannot set any child relationships and filter the objects

Hello;
Tne component looks slightly different in the version I downloaded and when I try to enter a child relationship it cannot fetch. When I save and navigate to record it gives "cannot read objectname" error. Would that be related with the Winter Release? I am sure this is the correct relationship name. Could you please help me on this?

image
image

Best Regards
Deniz

Question - take it one level up - to the account

Hi Douglas,

By my understanding, the files we see in the parent object is by the related to field in the task object.

Is it possible to take it one level up, so we will be able to see every thing under the account level?

For example:
Task that related to opportunity, will be seen in the related account of the opportunity.

Thanks, Lee.

Relates Files includes ContentNote records

Hi @douglascayers - We have a custom object that is M:D to Account. I have added your configured to the Account page and it correctly displays Files related to the custom object.... but the list also include Notes related to the custom object in the list of related Files.
Is it possible to suppress Notes or to specify them explicitly?
Thanks!

Make Component available for mobile app

Is your feature request related to a problem? Please describe.

App works great on desktop, however is incompatible with mobile (specifically, the "new" Salesforce mobile app.

Describe the solution you'd like.

It would be nice if the component also rendered on mobile. If an admin does not want to display the app on mobile, they can control the visibility by device through their Lightning Record Page.

Additional context.

Not sure if you would have to restructure the layout into a true Accordion to leverage the portrait view of the mobile app, or if the current layout will stack appropriately. Still, having this available on mobile would be excellent!

Use Actual Related List Labels

Due to limitation in Apex, the SObject Describe info only provides the API name of child relationships or the label of an object, not the label of the child relationship.

See this StackExchange post about the limitation.

This means if we have an object Foo__c with two lookup fields to object Bar__c and each lookup field assigned different related list labels like "Mars Bars" and "Candy Bars" then Apex code isn't able to determine those labels. Instead, Apex SObject Describe info can tells us the API names like Mars_Bars__r and Candy_Bars__r or the labels of the Bar__c object itself: "Bar" (singular label) and "Bars" (plural label).

For now, the app displays the plural label of the object the lookup field points to. It's not ideal, but better than nothing. If you mouse over the relationship name in the vertical navigation then the tooltip that displays includes the API name of the child relationship.

This means that if a child object has multiple lookup fields to the same parent object then the Related Files lightning component will display the parent object's plural label multiple times too.

image

Cory Cowgill suggests trying to use the User Interface API but I fear it may have same limitation as Apex.

See files of parent records?

Hi,

Is this component able to show the files that are linked to a parent record.
For example, on a Contact page, find files of the parent Account?

Thank you,

unable to relate attachments from emails

@douglascayers Hi Doug, awesome plug in except for one little issue. Im trying to pull in attachments from emails, however, when i include Emails to the Child relationships, nothing is populating. Since these emails show up in the activity history, i've tried to pull in 'activities' into the child relationships but the lightning page builder just keeps spinning and wont complete.

These emails were attached through the SF for Outlook plug in and would originally have been related to that contact.

Not sure what i'm doing wrong so any assistance would be appreciated!

Community Support

love this app can't emphasis that enough. it would be great if it could be extended to support communities.

I got it working with a crude hack:

removed force:hasSObjectName as it's not supported
added in a apex method to get the object name getSObjectType()
equally could have just added a new design element where you get the sobjectname and it would have worked.

had some file visibility issues but on the whole for the demo it worked to give a good idea of the kind of custom code option.

Translation

Translating labels for child objects

Most of the UI, e.g., the fields labels for the list showing files, translate automatically. The labels used for the child objects (Cases, Opportunities, Tasks, etc.) are shown in English and I cannot figure out how to translate these (other than maybe modifying the component source code). It would be great if there was a way to translate these labels.

Additional context.

Picture illustrating missing translation:
image

Filtering is case sensitive

Hi Doug

When adding the filters to limit the Related Files list (eg show only accounts, contacts, opportunities) the names you enter in the list are case sensitive. eg Accounts must have the first letter capitalised. If not, when you click out of the field to update the display it hangs with a little spinner and never saves the change. The multiple occurrences of labels is also a bit of a hassle but I see you are discussing that in another issue.

Recent Error - "Sorry, error initializing component"

what would prompt this error all of a sudden? it has been working fine, and then today in my sandbox i get this error whenever i navigate to this component. I am trying to view files on related records such as oppty's and contracts. This has been working great until...well not sure exactly but i checked it today and its giving me that error whenever i open that component. It worked last week, that much i know, and i've not made any configuration changes recently.
Any thoughts @douglascayers ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.