Slinger's Thoughts

August 14, 2008

two tricks I figured out recently for copying files, part 2.

Filed under: SharePoint — Tags: — slingeronline @ 8:38 am

As promised, here is part two.  If you read the post from the other day, you saw where I wanted to copy a file to a different document library depending on an item of metadata.  Well, when it was discovered that this was possible, some of the higher ranking at our company wanted me to do something similar, but add a step where a file has to be approved first.  I thought this was a perfect opportunity to implement the built-in approval workflow.  (I know, it’s sad, but I have to spoon feed the employees here because SharePoint scares them.)  Here is the problem, and then my solution.  We need 3 levels of permission for a file, one group should be able to edit the file at all times, one group should be able to view the file at all times but not be able to edit, and one group should only be allowed to view the major or “published” versions of the file.  We also want to add a step where a file cannot be “published” without the consent of another group.  Sounds simple right?  It basically is, with the exception of that one additional permission.  I don’t like changing permissions frequently, and I really don’t like creating new permission groups, simply because I have enough permission groups to begin with, with clients and vendors and internal employees and external employees and different employee groups, it gets to be a nightmare to maintain and manage, so I like to set permissions once and forget about it.

I set up a document library for our working files and named it, “working files.” (I thought about naming it “Donald Tweedlebaum,” but I think that would confuse some of our users.) We don’t want our clients seeing all of the work that goes into these files, as we want our customers to simply believe that we magically know what we’re doing, so I broke the inheritance of permissions on this document library and removed the client from having access to it.  I did add all NT authenticated users so that all of our employees could read the files contained there.  Basic permissions stuff.  I set minor and major versioning on the document library, and set it for content approval.  Hopefully most of you have already played around with the built-in workflows that SharePoint has so I won’t go into how to set up an approval workflow.  This is a required step though, since we required approval on items in this document library, there has to be a way to get files approved.  The fun part is this though; How do we allow our clients to see an approved file?  They don’t have access to the working files document library for obvious reasons.  We need to get that file copied over into a document library that our client does have access to.  But only the approved one, not a minor version.  Well, we can make a copy of it, almost exactly the same way we did before, with a few minor tweaks.

Part of the problem here is that we are not going to watch a column that users edit, but rather a column that our approval workflow edits, so we can’t do this exactly the same way we did before.  Go ahead and fire up your SharePoint Designer and create a workflow.  We want this to trigger automatically any time a file is changed. (It won’t make any difference if we select when a file is created or not, since when a file is created it is always a minor version and the workflow won’t trigger.)  We will need two steps to this workflow.  The first step will be to watch for a change in column data, and the second will be to actually move the file.  We can’t use a condition to check a column of metadata because that check will always occur before the approval workflow has completed, and in that instance, our workflow will do exactly nothing.  (This drove me nuts until I got some help from some actual experts.)  So, instead of a condition for our first step, we need an action.  Select “Wait for Field change in current item,” and for field, select “approval status.”  We want to perform the next step when the approval status field equals approved, so leave the “to equal” and select “0;#approved” for the value.  (If you have selected the correct field, then the options will look similar to that.)  Add a workflow step on the right hand side of the workflow dialog, and then add another action.  I did two things, one was to copy the current file to another document library in the same site.  Now when a file is approved, it automatically gets copied over to a document library that our client does have access to.  So now I have a set up where one group can edit a file, while the company can see the working file, but the client only has access to a copy of the file that is approved for distribution.  I also elected to send an e-mail to our documentation dept so that they were always aware of when this file would be updated. This way they could notify the appropriate people that the file has been updated.  I haven’t tried to combine both steps into one step, but this way makes it easier to tell which part of the workflow does what.  Once you have this set up, take it out for a test drive and see what happens.

Create a file in the “working files” directory, make a few changes, and then check in the document as a “published” version.  This should automatically start the approval workflow if you have it set up.  Let the approval workflow run, and have someone approve the file.  Then sit back and watch as SharePoint completes the approval workflow and copies the “published” file over to a different document library.  Doing this we have basically created one additional permission level on a document library, by using another one.  Using it this way also lets everyone know that certain files are only for reference, and shouldn’t be used until they are approved.  I will present this solution to the managers who asked for something like this later today.  Hope it goes well.

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: