Follow the below steps to add the related object Field Name to the downloaded File Name:
Step 1 - Create Formula Field
- Go to the "Setup".
- Take an example of Opportunity Object, Once files have been downloaded from the "Opportunity" Object, they should contain the "Account" Object fields on the downloaded Folder Name.
- From "Object Manager" select “Opportunity” Object.
- In the “Fields & Relationships” click on the “New” button.
- Select Formula and then Next.
- Add a Field Label and Field Name, Select Formula Return Type as “Text” and then Next.
- One by one add field names from the “Insert Field” button as shown below.
- You can add multiple fields as per your choice and then click on Next, Next, and Save.
- Now the Formula Field is ready, Take this formula field API name.
Step 2 - Add Formula Field API Name on Excluded Object
- Go to the Excluded Object (Follow this step if the Excluded Object tab is not added - How to rename a downloaded file with a custom suffix?)
- Now add this field API Name in the “Excluded Object” under the “File Name Suffix” column as shown below.
Now, the Account Field name will appear in the file whenever you download a file from the Opportunity object.