cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper IV
Helper IV

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
Highlighted
Super User III
Super User III

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 - get item1-Trigger - get item2-Compose Year Init variable2-Compose Year Init variable3-Get increment value to be used3-Get increment value to be used4-Condition and update item4-Condition and update item5-Convert to integer5-Convert to integer6-add 1 to the increment value6-add 1 to the increment value7-Next increment value to be used if condition is yes7-Next increment value to be used if condition is yes8-Current list with generated values8-Current list with generated values

 

 

 

View solution in original post

17 REPLIES 17
Highlighted
Helper IV
Helper IV

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

Highlighted
Kudo Kingpin
Kudo Kingpin

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?

Highlighted
Helper IV
Helper IV

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

Highlighted
Kudo Kingpin
Kudo Kingpin

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

 

Highlighted
Helper IV
Helper IV

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

Highlighted
Super User III
Super User III

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 - get item1-Trigger - get item2-Compose Year Init variable2-Compose Year Init variable3-Get increment value to be used3-Get increment value to be used4-Condition and update item4-Condition and update item5-Convert to integer5-Convert to integer6-add 1 to the increment value6-add 1 to the increment value7-Next increment value to be used if condition is yes7-Next increment value to be used if condition is yes8-Current list with generated values8-Current list with generated values

 

 

 

View solution in original post

Highlighted
Helper IV
Helper IV

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

 

Highlighted
Super User III
Super User III

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

Highlighted
Helper IV
Helper IV

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

Highlighted
Super User III
Super User III

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

Highlighted
Helper IV
Helper IV

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

Highlighted
Super User III
Super User III

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.

Highlighted
Helper IV
Helper IV

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

Highlighted
Helper IV
Helper IV

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.

Highlighted
Super User III
Super User III

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

Highlighted
Helper IV
Helper IV

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.

Highlighted
Super User III
Super User III

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
FirstImage

Microsoft Ignite 2020

Check out the announcement of Power Platform content at Microsoft Ignite!

thirdImage

Experience what's new for Power Automate

Join us for an in-depth look at the new Power Automate features and capabilities at the free Microsoft Business Applications Launch Event.

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (10,250)