cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lairpr
Helper I
Helper I

PowerApp SQL Database

Hi,

 

I am trying to create an app that stores the data into a couple of SQL tables. I have one section that I am creating a repeated table kind of like in InfoPath. But when saving the data into the second table I get different errors. 

 

 

Colelction for Repeated Table
ClearCollect(
    ForCollection,
    {
        ReqForName: "",
        Name: "",
        ReqForEmail: "",
        ReqForId: "",
        Company: "",
        Supervisor: "",
        SupervisorEmail: "",
        ContractStartDate: "",
        ContractEndDate: ""
    }
);


OnSuccess - Form1
ForAll(REQUEST, If(!IsBlank(ComboReqFor), Patch(REQFOR, Defaults(REQFOR), {FORID:ComboReqFor.Selected.Id , NAME: ComboReqFor.Selected.DisplayName , FORNAME: ComboReqFor.Selected.DisplayName, FOREMAIL:ComboReqFor.Selected.Mail , COMPANY:txtCompanyReq.Text, SUPERVISOR:ComboReqForSup.Selected.DisplayName, ENDDATE: DatePickerEndDate.SelectedDate, STARTDATE:DatePickerStartDate.SelectedDate, REQUEST_ID:RequestFrm.LastSubmit.ID})));

Errors when saving the data
"The Item has already been created in the server"

The requested operation is invalid. Server Response: REQFOR failed: Microsoft SQL: Violation of PRIMARY KEY constraint 'PK__REQUEST__713959CAD9F86543'. Cannot insert duplicate key in object 'dbo.LISTFOR'. The duplicate key value is (f412ad3c-0fde-440f-936d-62e7ce2719d5). inner exception: Microsoft SQL: Violation of PRIMARY KEY constraint 'PK__REQUEST__713959CAD9F86543'. Cannot insert duplicate key in object 'dbo.REQFOR'. The duplicate key value is (f412ad3c-0fde-440f-936d-6...

The requested operation is invalid. Server Response: LdC_REQ_FOR failed: A value must be provided for item. clientRequestId: a98e22be-6f9d-43ba-9fa2-1e137c3af5f2

And no error but the data from the collection is not saving and no errors are displayed.

SQL Table Examples
ListFor
ID
RequestId - PK
RequestId
Other Columns....

LISTFOR
ID-PK
RequestId - FK
Other Columns....

 

 

Any help will be very appreciated. I have been struggling to save the data for almost t a week now. 

 

Thank you

0 REPLIES 0

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (2,675)