cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SamPo
Power Participant
Power Participant

Create a new record with AutoNumber - CDS

Hi,

I have an entity in CDS with an autonumber field that is also a required field (it is my primary field).

When I use the 'Create a new record' action in my flow it defines this as required field and hence won't let me save the flow if I leave it blank. I've tried to use 'null' and this actually creates a record with a null value (not what I want).

The obvious solution is to lookup the last record in the entity and calculate this value myself but it seems like there should be a better solution.

Is there any way to submit this action in a way which will force the entity to create this value for me?

Thanks

Sam

 

5 REPLIES 5
v-litu-msft
Community Support
Community Support

Hi @SamPo,

 

I'm afraid Flow can't do this because there are no global variables.

Usually in this case, what I suggest is that you can store the ID in a text file or SharePoint list, and if you create a record, use Get item to take it out of the SharePoint and add it to the new CDS record.

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

SamPo
Power Participant
Power Participant

@v-litu-msft How will storing a value in Sharepoint help here? I don't see what the relevance is here to a global variable.

The issue here is I should be able to create a record in CDS without including this item and then the database should generate the next available record for me.

If this isn't possible using the connector in Flow then I will just calculate this myself - I will take the value of the last record and add 1. Don't understand why I need a global variable here..

v-litu-msft
Community Support
Community Support

Hi @SamPo,

 

The global variable is a record of the AutoNumber, in Flow there is no such feature, but you can create a function-like value in SharePoint specifically to store this automatic number. When create a record in CDS, just need to do is take it out of Get item, after creating a record, increase the value in SharePoint.

Of cause, as an alternative method, take the value of the last record and add 1 could work, both are ok.

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

MCJ
MVP

Hi Sam

 

This might sound like a stupid question, but why don't you just make the autonumber field not required? Primary fields don't have to be required in CDS and if the Autonumber function is taking care of populating the field, you don't need to have it required. Whenever I create an autonumber field, i always make it optional for reasons like this.


Old school Classic Workflows in CDS/D365 have this same issue, whenever we needed to automate something which have a required field but we weren't setting that value. We'd have to update the form so that the fields were optional, create a workflow and then go make the fields required again. It means it would work, but would be a lot of work to update it. I think that's why it's ingrained in me to not make autonumber fields required.

 

thanks

Matt

SamPo
Power Participant
Power Participant

@MCJ Thanks yes I am aware of this and have achieved the same by populating it just with 'null'.

The issue here is that I rely on this number in a number of places in both the app and flows connected to this solution so I need it to be filled out.

 

I will go with the option of calculating this myself.

Thanks

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (1,901)