cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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
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
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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (7,533)