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

Generating Autonumber from Canvas Apps when the primary field in CDS table is autonumber

I'm trying to generate Autonumber for the primary field in CDS Table, but the Defaults() doesn't do it for me when trying to create a record in the CDS Table as I get an error in Patch() that mandatory field is missing. Any workarounds here to generate the Autonumber from Canvas Apps?

1 ACCEPTED SOLUTION

Accepted Solutions
v-siky-msft
Community Support
Community Support

Hi @Dchandna ,

 

If you want to generate autonumber for primary field, you should change the data type of primary field to Autonumber, and uncheck Required option.

Then you can use patch() and Defaults() functions to create a new record, the primary field would generate autonumber. Such as:

 

Patch(AutoNums,Defaults(AutoNums),{Title:"GG"})

Annotation 2019-10-04 151651.png

Best regards,

Sik

 

 

View solution in original post

3 REPLIES 3
v-siky-msft
Community Support
Community Support

Hi @Dchandna ,

 

If you want to generate autonumber for primary field, you should change the data type of primary field to Autonumber, and uncheck Required option.

Then you can use patch() and Defaults() functions to create a new record, the primary field would generate autonumber. Such as:

 

Patch(AutoNums,Defaults(AutoNums),{Title:"GG"})

Annotation 2019-10-04 151651.png

Best regards,

Sik

 

 

View solution in original post

Thanks didn't know primary field "required" can be unchecked in CDS

Sik,

I was wondering if you could look at my post here:

CDS Question and Autonumbers

It appears to be the same problem and I unchecked "required", but I am not understanding how your code brings in the autonumber for the Entity.

 

Regards,

Jason

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Microsoft Ignite 768x460.png

Find your focus

Explore the latest tools,training sessions,technical expertise, networking and more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (1,685)