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

CDS - Autonumber not generating for new record

I am trying to build a PowerApp that uses Talent-related entities in CDS, such as Leave Requests and Leave Request Details. The idea is for the user to be able to create a new leave request, and then update the related entities from the PowerApp.

 

Here I am running into an issue: Even though the Leave Request Details entity has a column named Leave Request Entity Number, which is set to be Autonumber, it does not get generated properly.

 

In screen "NewLeaveRequest" I have two forms, which are both set to FormMode.New: Form1 and Form2. Because I need to generate one record per date of leave, I also have a collection called LeaveRequest which is generated when the submit button is hit. The submit button then fires off a SubmitForm(Form1).

Form1 then runs. OnSuccess it will fire a Refresh('Leave Requests') and UpdateContext(LeaveRequestNumber...) with the latest generated Leave Request Number for this user. Then it will call a ForAll(LeaveRequest, SubmitForm(Form2)). 

This runs fine every time and the Leave Request Number is generated as expected.

Form2 then runs. OnSuccess it will fire the following:
Refresh('Leave Request Details'),
 If(DateValue2.SelectedDate < _LeaveToDate,
UpdateContext({_LeaveDate: DateAdd(_LeaveDate,1,Days)}),Navigate(TimeOffOverview,ScreenTransition.Fade))

So far, Form2 only manages to run once before failing with "There was a problem saving your changes. The data source may be invalid".  I have tried using PATCH(), which fails with an error about record already existing on server side. 

In Leave Request Details, I have set Leave Request Detail Number to not required, as suggested in other threads. I have reconnected the data source and I have recreated the form multiple times, and I am now out of ideas on how to fix this. 

How can I make this work? 

1 ACCEPTED SOLUTION

Accepted Solutions
Frequent Visitor

I retried the PATCH() setup. Turns out I had used a wrong input for one of the columns, hence why it failed. It now works, case closed.

View solution in original post

1 REPLY 1
Frequent Visitor

I retried the PATCH() setup. Turns out I had used a wrong input for one of the columns, hence why it failed. It now works, case closed.

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!

Users online (79,323)