Publish item and link Activity - Should item deletions be cascaded?

Feb 10, 2010 at 4:50 PM

Hi Ryan

I have been playing with your Publish item and link custom activity today in Sharepoint Designer.  I am using it on a documents library to publish items out to a duplicate document library.  This is just a test case.

My document library has some custom fields and is designed for uploading existing documents, not creating new documents from templates. When I first started using your activity earlier today it seemed to work perfectly.  I could upload a document, enter the custom field data and when the document was saved, it would immediately be publsihed to the duplicate list.  Updating the document or meta data would equally cleanly update the document in the duplicate list.  Also, I am sure that if I deleted the item from the main document library, that deletion was being cascaded through to the duplicate list with the corresponding item being deleted from the duplicate list.

However, now the activity does not seem to be working correctly and I cannot figure out why.

  1. The activity is still triggering and publishing the item from the document library whenever the source item is uploaded or edited.  However, after uploading a document, if I fill in the metadata and save, I get shown a sharepoint error page indicating that the record cannot be saved because it is currently being edited.  If I don't fill in the metadata the item saves ok and the activity works ok and publishes.
  2. Deleting a published item from the main documents library is now not cascading through to the duplicate library.  The corresponding item is not being deleted from the document library.

In order to try debugging I have updated a view on the main document library to show your "Published To" field.

The duplicate list I am publishing to is located at URL http://data-server:83/tempdocuments/

After I upload a document to the main library for the first time, the activity runs and I see an entry in the "Published To" field of http://data-server:83/tempdocuments/forms/dispform.aspx?id=8;

However, if I look at the duplicate list, the id of the item just published is actually 9.  Is this expected?  This behaviour is seen across all published documents.  There is always an offset of 1 between the published id in the "Published To" field and the actual id of the item in the duplicate list?

The one thing that has happened between the activity working and not working is that wss 3.0 service pack 2 was installed onto our server.  I know there were some changes in sp2 to prevent workflows entering infinite loops due to changes made to the list item by the workflow itself.  Could this be anything to do with why the activity appears to not work now?

I'd appreciate any info as to what may be happening and if what I am seeing currently is expected or unexpected behaviour.

Thanks in advance

Nick

Coordinator
Feb 10, 2010 at 5:18 PM

Nick,

That is definitely not the correct behavior.  This activity creates a column in the source list that will point at the destination list and one in the destination list that will point back at the source.  When you add these to your view, you should be able to click from source to destination and back again. 

Is the field in the destination list pointing back to the correct source item?

I think that SP2 was installed on the machine I developed the code on, so that doesn't seem like the cause, but I will double check that.

In the mean time, if you find/solve your problem pleas post back your solution.

-Ryan

Feb 10, 2010 at 6:28 PM

Hi Ryan

The field in the destination list is pointing back to the correct source item.  I can't do any more with it today but I will do some more experimenting tomorrow and post back any findings.

Nick

Feb 13, 2010 at 12:35 PM

Hi Ryan

I've done a bit more work on this and I think I have isolated the problem.  When I was testing before I was trying to publish between two document libraries on the same website.  This seems to be the problem.  If I try to publish between site collections or between web appplications, the activity works fine and in these cases, the links in both the source list and destination list are the correct.

It seems from my work now that you only need to run the Publish item and link custom activity one time on any particular list item, e.g. run it on the basis of a new item being created.  It does not need to be run subsequently on an item change trigger.  Your code seems to automatically keep the lists synchronised (including deletions) without running the activity again. Is this what you expect to happen?

On the above basis, I have two remaining issues with the activity:

  1. If  I run the activity inside a "New Item" workflow, I often get an error of type "The file DocLib/Costing R1.xlsx has been modified by GENESYS\nicholasevans on 13 Feb 2010 13:16:28 -0000.".  However, if I go back to the list, invariably the activity has run and published the item.  Currently, it seems that if I add a pause into the workflow before running the activity (e.g pause for 5 minutes), I don't see this issue.
  2. In order for the activity to run, the current user of the source list must also be an authenticated user with sufficient permissions to create/edit an item in the destination list.   If the source list user does not have permissions on the destination list to create/edit items, the activity fails and does not publish or update the destination list entry.   It would be useful if the activity could be extended to take in a "user" parameter for the destination list or have some other solution to allow authentication against the destination list.

However, I have to say that this particular activity is one of the most useful items i have ever downloaded and played with from codeplex so thanks for the great work.  I'll try and get to playing with the other activities over the next few days.  Do you have any plans to make these activities sharepoint 2010 compatible?

Nick

Coordinator
Feb 17, 2010 at 5:51 PM

Hi Ryan

I've done a bit more work on this and I think I have isolated the problem.  When I was testing before I was trying to publish between two document libraries on the same website.  This seems to be the problem.  If I try to publish between site collections or between web appplications, the activity works fine and in these cases, the links in both the source list and destination list are the correct.

Interesting. I'm not sure why that would be, but I do know I only ever used it from one collection to another.

It seems from my work now that you only need to run the Publish item and link custom activity one time on any particular list item, e.g. run it on the basis of a new item being created.  It does not need to be run subsequently on an item change trigger.  Your code seems to automatically keep the lists synchronised (including deletions) without running the activity again. Is this what you expect to happen?

That is correct. It creates event listeners on the source and destination list.  The one on the source keeps the destination entry in synch, while the one on the destination just listens for deletes and removes the link from the source if that occurs.  If you want to control it a little more manually, you can use the "copy item to another location", "Delete Remote Item", and the "update remote copy" activities.

On the above basis, I have two remaining issues with the activity:

  1. If  I run the activity inside a "New Item" workflow, I often get an error of type "The file DocLib/Costing R1.xlsx has been modified by GENESYS\nicholasevans on 13 Feb 2010 13:16:28 -0000.".  However, if I go back to the list, invariably the activity has run and published the item.  Currently, it seems that if I add a pause into the workflow before running the activity (e.g pause for 5 minutes), I don't see this issue.

Do you know if it is complaining about the source file being changed or the destination?  Also, is approval turned on for either source or destination?  Is either source or destination checked out?

  1. In order for the activity to run, the current user of the source list must also be an authenticated user with sufficient permissions to create/edit an item in the destination list.   If the source list user does not have permissions on the destination list to create/edit items, the activity fails and does not publish or update the destination list entry.   It would be useful if the activity could be extended to take in a "user" parameter for the destination list or have some other solution to allow authentication against the destination list.

You could modify it fairly easily, but you'd need to take in both a user name and password to create the credential.  I think these things are stored in the workflow files as plain text, so I'm not sure you'd be able to find a good, secure option. 

One thing I will warn against is removing the impersonation from the code.  With a single comment, this activity could be running with elevated priviledges, which would solve your issue, but it would allows anyone with rights to create a workflow, to create/edit/delete content in any site regardless of their permissions.

However, I have to say that this particular activity is one of the most useful items i have ever downloaded and played with from codeplex so thanks for the great work.  I'll try and get to playing with the other activities over the next few days.  Do you have any plans to make these activities sharepoint 2010 compatible?

That's awesome, Nick.  Thanks!  I am definitely going to try to put out an SP2010 version of this as well as it's dependent components.

Sorry about the bold blue text there, but I wanted to respond inline.  Hopefully it's readable. 

-Ryan