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

 

 

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
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (1,356)