cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Impactful Individual
Impactful Individual

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

Impactful Individual
Impactful Individual

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

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.

Advocate IV
Advocate IV

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

Impactful Individual
Impactful Individual

@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
Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Microsoft Ignite

Microsoft Power Platform: 2021 Release Wave 1 Plan

Power Platform release plan for the 2021 release wave 1 describes all new features releasing from April through September 2021.

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (12,987)