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

Unique ID like 2019-01 with condition don't count other line items

I have a flow that creates a unique ID with the year 'yyyy' format, like 2019-01.

As last step, I entered the condition, that a column of my list has to contain a specific word.

The problem is that it then looks like this. After 2019-34 comes 2019-38. What I would like to have, is that after 2019-34 comes 2019-35.

 

074.JPG

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Unique ID like 2019-01 with condition don't count other line items

Hi @Dricc, forgive me for stepping into your conversation with @ErichH  but I have an alternative method in the images below which I hope you will find is a solution. The main thing is that whenever I deal with incrementing values I always save the inext value to be used, i.e the 35 you mentioned in yur first post, in a separate SharePoint list which only has that 1 item. The flow gets that number, updates the new item with it then then adds 1 to it at the end of the flow ready for the next item that meets the Condition.

In my example the Condition must be that Current is equal to Yes.

Image 5: as the number has been used in a string variable we need to convert it back to an integer ready to be saved to the increment list.

If the Condition evaluates to No then the number is not increased by 1, You can see this in the last image.

Rob
Los Gallardos
If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks.

 

1- Trigger-GetItem.png1-Trigger - get item2-ComposeYear-InitVariable.png2-Compose Year Init variable3-GetIncValue-Append.png3-Get increment value to be used4-Condition-Update.png4-Condition and update item5-Convert.png5-Convert to integer6-Convert-UpdateInc.png6-add 1 to the increment value7-NewIncValue.png7-Next increment value to be used if condition is yes8-CurrentListItems.png8-Current list with generated values

 

 

 

View solution in original post

17 REPLIES 17
Dricc
Level: Powered On

Re: Unique ID like 2019-01 with condition don't count other line items

My flow looks like this. I don't know if it helps.

 

083.JPG

Super User
Super User

Re: Unique ID like 2019-01 with condition don't count other line items

Are you sorting the data in the “get items” step by “ID”?

 

and 

 

Why is the “increment variable” step outside of the loop “apply to each”? What is inside of the loop?

Dricc
Level: Powered On

Re: Unique ID like 2019-01 with condition don't count other line items

Thank you @ErichH !

Please find my flow below. Does it help?

 

084.JPG085.JPG086.JPG087.JPG

Super User
Super User

Re: Unique ID like 2019-01 with condition don't count other line items

you have to

> move the "increment variable" step into the "apply to each" loop as you want to have unique numbers.

 

and 

 

suggest to add in "Get items" in 

> "order by" the dynamic variable ID .

> "filter by" the text  generated%20number ne  ''

 

Dricc
Level: Powered On

Re: Unique ID like 2019-01 with condition don't count other line items

Thanks a lot @ErichH !

just one question: what does this do and what is the dynamic variable exactly:

"order by" the dynamic variable ID

 

Also, the flow runs succesfully, but doesn't do what I want:

 

 

088.JPG089.JPG090.JPG091.JPG

Super User
Super User

Re: Unique ID like 2019-01 with condition don't count other line items

Hi @Dricc, forgive me for stepping into your conversation with @ErichH  but I have an alternative method in the images below which I hope you will find is a solution. The main thing is that whenever I deal with incrementing values I always save the inext value to be used, i.e the 35 you mentioned in yur first post, in a separate SharePoint list which only has that 1 item. The flow gets that number, updates the new item with it then then adds 1 to it at the end of the flow ready for the next item that meets the Condition.

In my example the Condition must be that Current is equal to Yes.

Image 5: as the number has been used in a string variable we need to convert it back to an integer ready to be saved to the increment list.

If the Condition evaluates to No then the number is not increased by 1, You can see this in the last image.

Rob
Los Gallardos
If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks.

 

1- Trigger-GetItem.png1-Trigger - get item2-ComposeYear-InitVariable.png2-Compose Year Init variable3-GetIncValue-Append.png3-Get increment value to be used4-Condition-Update.png4-Condition and update item5-Convert.png5-Convert to integer6-Convert-UpdateInc.png6-add 1 to the increment value7-NewIncValue.png7-Next increment value to be used if condition is yes8-CurrentListItems.png8-Current list with generated values

 

 

 

View solution in original post

Dricc
Level: Powered On

Re: Unique ID like 2019-01 with condition don't count other line items

Thank you @RobElliott !

That looks pretty good exept for the last part where the sister list is updated. I get following error:

 

092.JPG093.JPG

 

Super User
Super User

Re: Unique ID like 2019-01 with condition don't count other line items

The error message says the item doesn't exist. You must already have an item in that list.

Rob
Los Gallardos

Dricc
Level: Powered On

Re: Unique ID like 2019-01 with condition don't count other line items

@RobElliott, I do have an item in my list:

 

094.JPG095.JPG

Super User
Super User

Re: Unique ID like 2019-01 with condition don't count other line items

Could you post of screenshot of the Update item action that failed so we can what the issue might be in it.

Rob
Los Gallardos

Dricc
Level: Powered On

Re: Unique ID like 2019-01 with condition don't count other line items

Super User
Super User

Re: Unique ID like 2019-01 with condition don't count other line items

It looks to me like you've changed the list name from Trial2_sister to x4requests_sister? That might be the problem as Flow (and PowerApps) doesn't like it when list names, column names etc are changed. You could delete the connection and re-connect or perhaps delete and re-create the actions that refrence the sister list.

Rob
Los Gallardos
If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks.

Dricc
Level: Powered On

Re: Unique ID like 2019-01 with condition don't count other line items

Sorry I had created a copy of the flow, to test it on other lists that I have. This was the screenshot of this copy.

Here the original: I never changed the list name:

 

100.JPG

Dricc
Level: Powered On

Re: Unique ID like 2019-01 with condition don't count other line items

Note that I was obliged to enter something in the 'Title' column of list Trial2_sister because this column is required by default. I don't know if this can be an issue.

Super User
Super User

Re: Unique ID like 2019-01 with condition don't count other line items

No that won't be the problem. For some reason it doesn't seem to be finding the list and I'm not sure why that would be happening.

Rob
Los Gallardos

Dricc
Level: Powered On

Re: Unique ID like 2019-01 with condition don't count other line items

@RobElliott  it works now! I had the ID wrong. I had @{body('Update_item')?['ID']} instead of the @{items('Apply_to_each_2')?['ID']}

Thank you very much for your help all along.

Super User
Super User

Re: Unique ID like 2019-01 with condition don't count other line items

@Dricc, excellent! I'm pleased it works for you.

Rob
Los Galardos

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (4,835)