cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Crowie
Level: Powered On

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
Crowie
Level: Powered On

Re: CDS - Autonumber not generating for new record

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
Crowie
Level: Powered On

Re: CDS - Autonumber not generating for new record

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
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Users Online
Currently online: 305 members 5,706 guests
Please welcome our newest community members: