cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MH3
Post Prodigy
Post Prodigy

Uploading a file along with Form Details in Document Library

Hi,

I have a form which have some text input fields, Add Picture Control and Barcode Scanner Control

I want to Save the Text fields, Selected PDF, Excel file from picture control an scanned barcode to a document library list at the same time. Add picture control needs a button flow to upload a file to the document library. 

My Code: on SUBMIT BUTTON

UploadFileToLibrary.Run(UploadFileButton.Media,UploadFileButton.FileName)


Patch(
      'Vaccine Tracking List',
       Defaults('Vaccine Tracking List'),
       {
          
        EmpEmail: EmpEmailInput.Text,
        'Date of Certification': DataCardValue5.SelectedDate,
        VaccineType: DataCardValue6.Selected,
       CertificateNumber: DataCardValue7.Text,
       File: ???
            }
        );
    
Navigate(View,None);
ResetForm(Form1)




I want to include that in my patch command, I am confused any guide? 

FormDetials.png

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User III
Super User III

@MH3 

Why are you Patching an edit form??

You should be using the SubmitForm action to update what you need.

 

However, with either method your challenge is that you need to create the record first by adding a file...then from that you can alter the item properties.

Typically this is done by passing not only the file, but also the metadata associated with the record to the flow and then the flow will create the library record and then assign the metadata to it.

 

If you decide not to send the metadata to flow, then you have to do a little switch around on the form to get it to work.

In this scenario the concept is working with creating a new file in the doc library (as opposed to viewing and editing).

 

Set the Item property of the Form to : Colaesce(lclNewRec, Defaults(yourDocLibrary))

In your Submit button OnSelect action:

With({flowResultID: UploadFileToLibrary.Run(UploadFileButton.Media,UploadFileButton.FileName).recordID},

    UpdateContext({lclNewRec: Patch(LookUp(yourDocLibrary, ID=flowResultID), yourForm.Updates})
);

SubmitForm(yourForm)

 

You will need to change your flow to return the ID of the record that was created when you create the file in the library to a result called recordID

 

What the above does is then patches the result from the flow with the values that have already been entered on the form.  This will keep them all there on the form rather than blanking them out.

 

The final bit is just to do a normal submitform on the form.

 

This method works well for creating new library files and having a form for the metadata.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

1 REPLY 1
RandyHayes
Super User III
Super User III

@MH3 

Why are you Patching an edit form??

You should be using the SubmitForm action to update what you need.

 

However, with either method your challenge is that you need to create the record first by adding a file...then from that you can alter the item properties.

Typically this is done by passing not only the file, but also the metadata associated with the record to the flow and then the flow will create the library record and then assign the metadata to it.

 

If you decide not to send the metadata to flow, then you have to do a little switch around on the form to get it to work.

In this scenario the concept is working with creating a new file in the doc library (as opposed to viewing and editing).

 

Set the Item property of the Form to : Colaesce(lclNewRec, Defaults(yourDocLibrary))

In your Submit button OnSelect action:

With({flowResultID: UploadFileToLibrary.Run(UploadFileButton.Media,UploadFileButton.FileName).recordID},

    UpdateContext({lclNewRec: Patch(LookUp(yourDocLibrary, ID=flowResultID), yourForm.Updates})
);

SubmitForm(yourForm)

 

You will need to change your flow to return the ID of the record that was created when you create the file in the library to a result called recordID

 

What the above does is then patches the result from the flow with the values that have already been entered on the form.  This will keep them all there on the form rather than blanking them out.

 

The final bit is just to do a normal submitform on the form.

 

This method works well for creating new library files and having a form for the metadata.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (21,237)