You are viewing limited content. For full access, please sign in.

Question

Question

Filter and assign data according to a date.

asked on June 11, 2021

I want to scan a specific folder and have workflow pull a date that is entered into a field. After that I want workflow to assign a numerical order to a different field.

So as an example:

8/25/2021 would be assigned the number 1

8/26/2021 would get 2

And so on...

What I want to do is have workflow scan a ready jobs folder and assign an install order based on a date entered in a field. Oldest job would be assigned 1 and progress upward. The folder would be scanned each night to adjust as jobs become ready.

Is this even possible?

 

0 0

Answer

SELECTED ANSWER
replied on June 14, 2021

If I'm understanding what you are trying to do, here is one way (definitely not the only way) to complete that.

This loads some details of the entries into a multi-value token in LFWorkflow (the date, since that is what we are sorting by, the file name because I'm using that as the secondary sort option, and the entry ID as both the third sorting option and the way to identify the entry when it is time to push the sorted values back to the metadata fields.  Those are loaded into a string of text, as date (yyyy-MM-dd format), the file name, and the entry ID - in this layout, we can just sort the strings alphabetically.

After the multi-value token is sorted, we go through each value, using the entry ID to retrieve the entry and then populate the iteration value to the other field.

Here's what it looks like before (my fields are named Date and Stack Order - you can name them what you want, I just wanted to use fields I already had set-up).

After running the Workflow, here's how the results look.  You can see that all of the Stack Order fields have been populated, and if sorting by the column, you can see that the values are sorted in date order (with name as secondary sort):

Here's the set-up in LFWorkflow:

  1. Entry List - creates a single multi-value string token named "Entry Details".
  2. Retrieve Current List of Files and Metadata - searches your folder in the repository.  Make sure you select the "Date" field in the list of fields that are returned with the search results.
  3. For Each Entry - this cycles through the results from "Retrieve Current List of Files and Metadata".
  4. Append to Entry List - this appends 3 values to the "Entry Details" token: %(ForEachEntry_CurrentEntry_Date#"yyyy-MM-dd"#) - Name: %(ForEachEntry_CurrentEntry_Name) - ID#%(ForEachEntry_CurrentEntry_ID)
    1. %(ForEachEntry_CurrentEntry_Date#"yyyy-MM-dd"#) is the date from the search results, formatted as yyyy-MM-dd so that it can sort alphabetically.
    2. Name: %(ForEachEntry_CurrentEntry_Name) is the word "Name:" followed by the actual file name.  In this case of two files having the same date, this will allow the file name to be the secondary sort option.
    3. ID#%(ForEachEntry_CurrentEntry_ID) is the word "ID#" followed by the entry ID number.  This will allow it to act as a third sort option, but more importantly will allow us to retrieve the entry ID later in order to populate the values back to the metadata.
  5. Multi-Value Sorted - this creates a new token named "Multi-Value Sorted" which takes the "Entry Details" token as runs a Sort Ascending function on it.  Token value should look like this: %(Entry Details#@SortAscending@#)
  6. For Each Value - this cycles through all values in the "Multi-Value Sorted" token.
  7. Extract Entry ID - this a pattern matching activity to retrieve the entry ID from the string values of "Multi-Value Sorted".
    1. Input is: %(ForEachValue_Current Value)
    2. Pattern is: ID#(\d{1,15})
      1. This looks for the word "ID#" immediately followed by 1-15 numbers, and retrieves those numbers.
    3. Return the first match only.
  8. Find Entry - this should be finding the entry with ID equal to the value retrieved from the "Extract Entry ID" activity.  It should look like this: %(ExtractEntryID_Entry ID)
  9. Populate Interation Number to Metadata - be sure to select the entry that is found in the "Find Entry" activity, and populate the Stack Order field with the "For Each Value - Iteration" token.  Should look like this:   
0 0
replied on June 17, 2021

Thanks for the detailed answer!

It appears to be exactly what I am looking for.

1 0
replied on June 17, 2021

Fantastic!

0 0
replied on June 17, 2021

Hey guys-

Now that you've gotten it all worked out, I'm going to chime in to simplify this. No offense to Matthew--it's always easier to edit than create.

The search activity can do sorting, including multi-value sorting. So you can achieve a similar result by setting the Search to do the sorting for you, then iterate through the results and set the field value based on the loop's iteration.

 

3 0
replied on June 17, 2021

Oh, haha, you're totally right.  I had considered that at first, but didn't follow through thinking the sort by date would erroneously sort by month or day before year - but that would be a faulty assumption since workflow would know the field was configured as a date and sort it appropriately.  I took the scenic route simply because I made a faulty assumption and didn't bother to test that assumption.

0 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.