1

I have a document library that contains source files (they're source text files for a circuit simulator). When a user begins checking in a new or updated file I want to run verification code against the file prior to the check-in. If the file fails verification I want to inform the user and cancel the check-in.

I've written a program that uses the client object model to iterate through the source files in a document library and runs my verification code against each file. If the file fails I save the returned string (contains the reason why it failed) and inform the user when all files have been completed.

My goal is to run the same verification code but when an attempt is made to check-in the file.

My SharePoint dev experience is limited to checking files in and out via the SP client libraries. My verification code is currently written as a C# dll and returns text stating why verification failed.

What is the best practices way to implement this? Any suggestion of books, sites, tutorials, etc?

Thank you in advance for your time and assistance.

4
  • Is this SharePoint Online or On-premise? If on-premise, what year and version? Jun 21, 2016 at 17:35
  • My test environment is SharePoint 2013 online. The prod environment is on-premises SharePoint 2013.
    – Falconeer
    Jun 21, 2016 at 17:41
  • The code capabilities are pretty different for SharePoint Online and SharePoint on premise. You might run into some pretty big hurdles with that setup. I'm not saying it is impossible, just trying to save you some grief. =) Jun 21, 2016 at 17:43
  • Thanks kindly. Grief has been the operating environment for this project. :p
    – Falconeer
    Jun 21, 2016 at 17:49

2 Answers 2

0

You could try to implement a Web Service that calls your client side code. You can then create a workflow via SharePoint Designer to call that Web Service on Check-In. If it passes, let it continue through the check-in process, if it fails, then reject the check-in.

Working with Web Services in SharePoint Designer

3
  • It's a possibility. However the biggest stumbling block I've run into is how to tell a workflow NOT to check in an item but to activate and do stuff when a check-in begins?
    – Falconeer
    Jun 21, 2016 at 17:48
  • What if you instead had a workflow running on item change that checks in the item if the check is successful? nothingbutsharepoint.com/2011/12/08/… Jun 21, 2016 at 18:02
  • Honestly, @dylan-cristy method is better for On-premise if you have no intention of moving to SharePoint Online. Jun 21, 2016 at 18:05
0

If your prod environment is on-prem, and you are not worried about it moving to the cloud, you could take advantage of that and write an event receiver that will fire on ItemCheckingIn, which would allow you to do exactly what you are trying to do - run some validation code against the file in question and reject the check-in if necessary.

However, your biggest hurdle to getting that done is to get yourself an on-prem development/test environment where you can actually code and test the event receiver. (You can't use event receivers in SP Online.)

2
  • I totally agree. I'd much rather be doing this in Visual Studio. Unfortunately I don't have a machine I can set up as a dev box (win server, sharepoint, etc). It looks like I'm going to need to find one.
    – Falconeer
    Jun 21, 2016 at 18:09
  • If you can't, there are things in SP2013 called remote event receivers that basically just call a web service (that you have written) when the events fire. Then you could do the processing in your custom web service. I haven't done much work with them, but they would work on SP Online. If you google "sharepoint 2013 remote event receivers" you can find out more. Jun 21, 2016 at 18:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.