Create New Account record and ability to upload documents on same page

  • 1
  • Question
  • Updated 7 months ago
  • Answered
Hi is there a way to create a new account record and have the ability to upload documents on it on same page or a wizard?

I've know how to create multiple related records at once, but for the File upload, the record needs to be saved first.

Once i save the new Account, I cannot grab the ID

If i create another model with most recent created account (sort by created date and return 1 record)to just grab the id, it could lead to errors in the case 2 users create new accounts in a very short span of time.

Any Suggestions?

Thx
Photo of Dave

Dave

  • 5,538 Points 5k badge 2x thumb

Posted 7 months ago

  • 1
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
I've done this where I save the File Upload to the current user record and then update the record to point to the new Account once it's been saved. Somewhat janky though since the file is uploaded before the Account is created. So the UX can be that there is an extra file uploaded for no reason.
Photo of Mark DeSimone

Mark DeSimone, Official Rep

  • 11,050 Points 10k badge 2x thumb
Hi Dave,

This is easiest if your new Account record is in a model by itself (meaning, a model like NewAccount with just one row that holds the new record's data). When you save the new record in a model like that, the record stays in the model, but its Id should automatically be updated with the actual Salesforce Id, as long as you've included Id as a field on the model. So, after saving, the permanent Id # should be available, and from there you should be able to associate Content Documents with it.

A common way to set this up is by using a Wizard, where
1) User enters Account info into one model. Be sure to include the Id field in this model.
2) The "Next Step" button will first save the new record to Salesforce, and then proceed to step 2.
3) Allow user to upload a Content Document using the Account model as the parent model. 

This tutorial gives great information about the scenario I'm describing. Be sure to look at the section "File Upload In Wizards."

Also, the documentation on the File Upload component is important to understand. 

At the end of the account creation and file upload process, if you wish to show this link between the uploaded Content Document and the new account, the relationship between the two is actually stored in an object called ContentDocument link. You would be able to set up a separate model on ContentDocumentLink that uses a model condition to pull only ContentDocumentLink records whose parent Id matches the Id in your Account model.
(Edited)
Photo of Dave

Dave

  • 5,538 Points 5k badge 2x thumb
Thank you Mark!

I had done excactly same thing but model was not retaining ID when going to next step it seems

Now that I checked the Defer Rendering of Step Contents box, as per the instruction in link you shared, It works like a charm!

Thank you and thank you Pat for your  suggestion as well
Photo of Mark DeSimone

Mark DeSimone, Official Rep

  • 11,050 Points 10k badge 2x thumb
Excellent. I hadn't thought of that setting myself, so I'm glad you've highlighted here.