Comparing most recently created item with New item in List Workflow (getting previous item ID)

  • 25 October 2019
  • 1 reply
  • 2 views

Badge +8

Hi all,

 

I'm trying to create a workflow that will assign an item to someone based on who the last person was that a previous item was assigned to.

 

For example: There are three people: Person 1, Person 2 and Person 3. All of these people have been assigned items. I now have a NEW item and I need to know who to assign it to based on who got the last item. So, if person 2 was the last person to be assigned something, person 3 would be next.

 

The list is relatively large so I would first need to query those that have been assigned (obviously). I'm thinking my next step would be to get the ID of the last assigned item (highest item ID on the list - minus the new one of course), look at the person column and determine whos next from there.

 

My issue is that I cannot for the life of me figure out how to get that highest ID/last assigned item.

 

This would need to be a list workflow that runs everytime and new item is added and does not have a person assigned to it (some will be added with that person already in the column, others will not).

 

Any help would be appreciated.


1 reply

Badge +12

@Nates_Mom....it's simple :)

 

  1. First QL and sort it in descending order by ID (this way you'll have the latest ID on the top)
  2. Now in this QL get Assigned To as a collection
  3. Now create a number variable "num_Index" and set '1' as default value
  4. Use collection operation action
    1. Select collec_Assigned_To
    2. Select Get
    3. In Index, select num_Index
    4. Store it in either SLT or PG variable

Since you're requirement is to always get the value from the second latest item, we've hard coded the index value. Index numbering always starts from '0'.

 

Also just to make sure I get right data (in case multiple items gets created during almost same time), in my QL, I'll filter where Assigned To is not empty. If you put filter parameter then you won't need collection variable, index variable and collection operation action. You can simply store Assigned To value in SLT or PG variable but make sure you DO specify item limit in Output options and set as '1'.

Reply