cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Submit and patch at the same button

Hi all, 

 

I'm hopiong you can help me out. 

 

I have created an app with some fileds which take their data from SQL and one form in order to attache a file. I have created a button to save all these to SharePoint with patch and submit form, but my problem is that the submitForm doesn't work. 

 

I've used this as the onselect:

 

Patch(
'AVG PowerApp';
Defaults('AVG PowerApp');
{
ID0: StudentIdLbl.Text;
Comments: CommentsTextInput.Text;
Course: CourseDropdown.Selected.Value;
Student: StudentDropdown.Selected.Value;
Teacher: TeacherLbl2.Text
}
);;
SubmitForm(AttachementForm);;
Reset(CommentsTextInput)

 

At the attached file you can see the picture from my app for better understanding.

 

How i can combine at the same button the submitform for attachement and the patch for the other data ?

 

Thank you in advance.

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @v-xida-msft,

 

Finally, i choose to insert all the data to one Form and use at the submit button at OnSelect the SubmitForm in order to send them all at SP with one record.

 

I was looking for another solution that would send the data more quickly, but now i am ok.

 

Thank you very much.

View solution in original post

5 REPLIES 5
Power Apps
Power Apps

Hi @Ntinos,

It sounds like you want both SubmitForm and Patch to run at the same time. You can use Concurrent() to make them simultaneous:

 

Concurrent(
    Patch(
        'AVG PowerApp';
        Defaults('AVG PowerApp');
        {
            ID0: StudentIdLbl.Text;
            Comments: CommentsTextInput.Text;
            Course: CourseDropdown.Selected.Value;
            Student: StudentDropdown.Selected.Value;
            Teacher: TeacherLbl2.Text
        }
    );

    SubmitForm(AttachementForm)
);;

Reset(CommentsTextInput)

 

But I am wondering--is the Form in new mode or edit mode? Can you share more about that setup?

@Mr-Dang-MSFT

 

You have understood right!

 

I will try your code and i will inform you.

 

Also the powerapp that i have created is custom. Meaning that as you can see from the picture i have the "AttachementForm" which is connected to SP and i have separated some dropdowns,labels and one textbox which take their data from SQL. All these data i tried to save them every time at SP with one button.

 

If you need to send you any other information please tell me.

 

@Mr-Dang-MSFT

 

Hello,

 

I tried it and the code create two separate raws at SP. The first raw contains only the attache file and the second raw contains only the data from other fields(labels,drobdowns etc) without the attache file.

Community Support
Community Support

Hi @Ntinos,

Do you add two separated forms within the screen of your app? One form for data from SQL and another form for uploading Attachments?

Do you want to patch the other data along with the attachment files into your SP list data source (insert into same one record)?

Based on the formula that you provided, I think there is something wrong with it. The Patch formula you provided would insert a new record into your SP list, the SubmitForm formula you provided would also insert a new record into your SP list. They are in separated records rather than same record.

I assume that you only enable the Attachments field (Data card) within your AttachmentsForm, I have made a test on my side, please take a try with the following workaround:

Set the OnSelect property of the "Submit" button to following:

SubmitForm(AttachementForm)

Set the OnSuccess property of the AttachmentForm to following:

Patch(
   'AVG PowerApp';
    LookUp('AVG PowerApp', ID = AttachmentForm.LastSubmit.ID); /* <-- Modify here */
    {
     ID0: StudentIdLbl.Text;
     Comments: CommentsTextInput.Text;
     Course: CourseDropdown.Selected.Value;
     Student: StudentDropdown.Selected.Value;
     Teacher: TeacherLbl2.Text
    }
 );;
Reset(CommentsTextInput)

Note: I assume that the StudentIdLb1, CommentsTextInput, CourseDropdown, ... etc are all in another form (not the AttachmentForm) which retrieves data from SQL. If the StudentIdLb1CommentsTextInputCourseDropdown, ... etc also in the AttachmentForm, please use SubmitForm function to submit your data instead of Patch function.

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-xida-msft,

 

Finally, i choose to insert all the data to one Form and use at the submit button at OnSelect the SubmitForm in order to send them all at SP with one record.

 

I was looking for another solution that would send the data more quickly, but now i am ok.

 

Thank you very much.

View solution in original post

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (72,405)