I have a custom registration form that users must submit proof of business to open an account.
I can create a contact, add labels, and such, but I would like to be able to attach their proof of business or tax exemption documents to their contact data. When viewing the contact from the dashboard, I can manually add a document. However, I can not figure out how to do it when creating the contact following form submission.
Working in
Dev Mode
What I’m trying to do
Describe the goal or outcome you’re hoping for
What I’ve tried so far
I scoured the documentation and found the Attachments API, which I believe is what I need, but I’m having trouble figuring out how to implement it.
I have been struggling to grasp the syntax of the new documentation.
This tells you how to add a document to your contact. It is very straightforward. It should be the same for a contact you created manually or one that was created as a result of a form submission.
Step-1: A new user is on your registration form. Step-2: The user do the registration (but incomplete, because proof docs missing due to no automation ???) Step-3: Then you as admin do proof every user manually by your own?
This is what i read out of your messages…
When viewing the contact from the dashboard, I can manually add a document.
Manually? Really?
But here…
However, I can not figure out how to do it when creating the contact following form submission. …i hear a cry for automation, not so???
Yes, I am trying to automate the process of attaching documents to a contact when they register for the site.
I am pretty sure that it is possible using the Attachments API, however, the documentation looks completely foreign to me. I can’t figure out where to even start.
To make your setup completely automatic you will need the following steps.
1) You will have to code an → UPLOAD-BUTTON ← and connect it to your form-submission.
2) User will fill out all the fields and attach a file (for example pdf-file or similar).
3) The upload then will go to the Wix-Media or Wix-Content-Manager, once the user has completed the form and clicked onto the submission button.
4) Once uploaded the file you get the corresponding file-URL, now you can use that file-url and save it inside of the contact’s extended field.
So when you open the contact, you should see that attachment (URL).
a) ABOUT —> EXTENDED FIELDS…
b) ABOUT —> WIX-MEADIA…
c) ABOUT —> WIX-FORMS…
So now all your users would be able to attach files by their own to their submissions and you could directly check the url inside the extended field (clicking on it or at least copy and paste to get a look onto it). Now you as the OWNER can decide if you want to approve that new contact/member, or not, after reviewing his attached document.
Even this last step could be automated aswell, but this would need a lot of coding. So the last approvement step will still be on you —> you check the attachment and decide what to do → approvement or declinement.
I did that at one point. I tried using the extended fields to attach the documents, but they were not downloadable (I think that was the issue with doing it that way; it’s been a while since I tried that).
I was hoping that someone had experience using the method in this documentation and could share their code to get me started.
I successfully automated the process of attaching a document to a contact from registration and provided a downloadable link for the document in a triggered email. The trick was using the url returned from getDownloadUrl instead of the url returned from the upload button.
/*********** FRONT END CODE *************/
import { getDownloadUrl }from "backend/media"
let downloadURL
$w.onReady(function () {
$w("#uploadDoc").onChange(()=>{
$w("#uploadDoc")
.uploadFiles()
.then(async(uploadedFiles) => {
// For each downloaded file
uploadedFiles.forEach(async(uploadedFile) => {
// Get a downloadable url
downloadURL = await getDownloadUrl(uploadedFile)
});
})
.catch((uploadError) => {
let errCode = uploadError.errorCode; // 7751
let errDesc = uploadError.errorDescription; // "Error description"
});
})
})
You’ve now used it correctly with Wix Media via Velo, without needing to rely on the REST API.
To work with the REST API, you’d likely need to use Wix Headless, since that requires authentication through a token along with a client or account ID. That’s why I initially mentioned Wix Headless.
It looks like the information I shared earlier helped point you in the right direction—well done!