Skip to main content
Nintex Community Menu Bar

There are many posts about this, but they’re all pretty old and the architecture has shifted around quite a few times.

Pretty simple request with a lot of complexity underneath: I want an unauthenticated user to be able to create a custom object record, and then upload a file related to that record.

I’m trying to do this in a Lightning Aura Exp Cloud site (if I’m not mistaken, LWR is not yet supported).

I’ve got Skuid showing up and the fields in a form. File Upload is rendering - the only configuration that works is Content Document with no model selected. I cannot seem to figure out how to relate it to the record that’s being created.

I tried having the File Upload component inject a custom file name or description, which could then theoretically be used by a Flow or Apex to go find and then relate the two records on the backend, with system context. But no dice yet - the custom values do not get saved on the file in Salesforce.

It looks like this is a problem for folks even in Flow. From what I can tell, if I can get the ContentVersion Id from the uploaded file, and then create another record that includes that ContentVersionId and the record Id of the custom object that’s created, we could then use Apex or Flow to associate them after the fact.

https://salesforce.stackexchange.com/questions/396284/guest-user-unable-to-upload-file-from-flow


Follow-up question: is there a way to get the record Id of the ContentDocument record that gets created as a result of the File Upload?

I’m sure there’s an API response from Salesforce somewhere that could be exposed; if I can store the returned ContactDocument Id on a field in the new custom object record, then Flow or Apex can take care of the rest, server-side.


Hey,

My dev has accomplished a similar request, by using a VF page and iframing it on site

VF Page: 
 

<apex:page showHeader="false" sidebar="false" standardController="your_object__c">    <apex:includeLightning />    <!--Lightning Container-->    <div style="width:100%;height:100px;" id="LightningContainer"/>    <script type="text/javascript">    //get account Id from URL    var recordId = "{!$CurrentPage.parameters.id}";         //Create Lightning Component UploadFileVfpage    $Lightning.use("c:sampleAuraFromVF", function() {        $Lightning.createComponent("c:uploadFileComponent",                                    { "parentID" : recordId }, //Pass Parameter                                   "LightningContainer", function(component) {                                       console.log('Component created');                                   });    });    </script></apex:page>


then on a template field:
<iframe src="/apex/c__UploadFileVfpage?Id={{{Id}}}&isdtp=vw" width="100%" height="140px" frameborder="0"/>


Dang. Ok. Welp, good to know. Thanks David!


Alright, so I’d rather *not* do an iframed VF page - kudos to y’all for making it work, but I’d really like to keep this as code-lite as possible, and we’re already in an Aura site - meaning that this would be a Lightning component inside a VF page inside an iframe inside a Lightning Aura site. 

Main question for the Nintex folks is this - the File Upload component is “using” the Lightning File Upload, which presumably makes a POST call to Salesforce to create a ContentDocument record. Is there any way to capture the response from that POST call, which I believe would include the new ContentDocument record’s Id? Then we could include that in the form data, which could then be used to run a Flow server-side to associate the custom object record and the new ContentDocument file.


Caveat that we’re getting into Salesforce specific APIs and behaviors here, not Nintex Apps functionality, so I can make no guarantees that this will work, but I did have a thought that I don’t mind sharing. 

The Lightning File Component publishes an “uploadfinished” event when an upload completes, and per the Salesforce docs, the event data does include the documentId as long as you aren’t using the unauthenticated guest user. It seems that if you are going the unauthenticated guest user route, Salesforce isn’t going to let you have that ID no matter what, and this approach would take code to pull off, but it’s documented by Salesforce, so I think it’s worth exploring.


Couldn’t you use the Case Object?  Surely that allows both uploading files and a response.  Once the file is in SFDC you could do whatever you want with it.


Well hey guys! Happy Thirsty Thursday to you.

J11 - I found that, and I’m very interested in it, but I’m not sure how to subscribe to that event *from* the Skuid page. That potentially solves one problem; if I can capture the uploaded file’s filename, I can at least store that on the form submission to help with matching later.

Greg - I think that’s actually where a lot of the frustration is in the SF community; even with a Case it’s still a challenge. But it sounds like there’s a (relatively) straightforward solution with the Lightning Upload component (which I think Skuid’s File Upload uses when in Lightning) that’s pretty interesting: it can accept a value for two attributes, file-field-name and file-field-value. You can add a custom field to ContentVersion, and if you reference that field in file-field-name, you can pass a value to it via file-field-value, as part of the upload process.

Theoretically, this would allow you to generate a random, unique key on page load, populate that key to a field on the new object record (or Case record), and then also populate it to the custom field on ContentVersion; then, after submission, SF Flow or Apex could handle relating the two to each other on the backend very easily. 

The only challenge is that I haven’t been able to figure out how to pass in params for file-field-name and file-field-value to the Skuid File Upload component.

https://salesforce.stackexchange.com/questions/331320/examples-of-lightning-file-upload-for-community-guest-users


Reply