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

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
Level 10

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

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
Level 10

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

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

Dchandna
Level: Powered On

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

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

JasonF
Level: Powered On

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

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
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.

Top Kudoed Authors (Last 30 Days)
Users online (6,552)