Here is our use case...
Customer selects 30 documents in the repository, edits the metadata and changes "approved" field to "yes". This triggers a workflow instance on each document that performs some lookups, moving the document and creating a shortcut in a specific folder.
For ease of description, let's say I have 3 documents called York, Harrisburg and Lancaster. All 3 have a "State" field set to "Pennsylvania" and a "Approved" field with blank or "yes" as options.
There is a workflow with a starting rule of "Metadata changed" and "Approved field is not empty".
In the workflow, we create a folder called "Pennsylvania" with a subfolder named as the County (ie York). It then searches a "Shortcuts" folder for entries called "York". If it finds it, it deletes it. In either case, it then creates a new shortcut to the "York" folder.
Here is the problem...
1. The Move (create shortcut) and Route Entry (Create Shortcut) activities will not overwrite an existing shortcut, it will duplicate it as "York(2)" for example. This is why it has to search for existing shortcuts of the same name in the destination folder and delete them first.
2. If I select 20 entries and change the "Approved" to yes, it runs all 20 instances at the same time. The problem is...
1. Instance 1 runs, finds there isn't a shortcut that already exists and will create one
2. Before Instance 1 can create the shortcut, Instance 2 runs, finds there isn't a shortcut that already exists (since instance 1 hasn't actually created it yet) and will create one.
3. Instance 1 then creates the shortcut "York"
4. Instance 2 tries to create the shortcut "York" since it didn't exist, but between the search and creation, however it now does exist so it creates "York (2)".
As a workaround, we created a separate workflow to invoke the processing and wait to invoke the next one until the current one is completed. This works, but drastically increases how long it takes to process all 20 entries.
How can you overwrite a shortcut?