Wednesday, July 17, 2013

Upload Tracking Without Analytics

Sharepoint does a lot of enterprise-level things well, assuming you have many enterprise trained technicians to operate it, and learn the hidden languages of Exchange Server. Or whatever they're using back there, I assume it's something related to SQL. But let's say you're cut off from your out of the box analytics and you still want to be able to see each and every document uploaded into the site. Then you want to copy and paste that information into an excel table, presumably for Metrics.

There is probably a better way to do this sort of Metrics, but the thing about a closed development environment like MS is that it is not so hot at the SEO, and that means I can't find anything of value by googling "Sharepoint 2010 track user uploads." I have to believe this is traced in the logs somewhere, but really: there's faster way.

Here is where we get into customising the CQWP, or the Content Query Webpart, also known as the webpart that lets you see what is going on in your installation. The CQWP is the backbone of Sharepoint list investigation, and can be transformed to do a vast number of data-display tasks, as Heather Solomon once recorded (gosh she's great).

So. Open up Sharepoint Designer. Be prepared to revert everything, an awful lot. I recommend doing this in, say, a totally separate Sharepoint from your main one, because borking this will bork the site.
  1. Go to your Style Library.
  2. Copy your XSL Style Sheets Library into a new sub-folder so you can edit the CQWP main styles without destroying all your pre-exisiting content rollups for your whole site.
    1. Failed at that? Revert everything to the site definition in Designer. You saved your code, it'll be fine.
  3. Create a content webpart wherever you want it to live, note dismally that you will be writing some new styles for this, and export it.
  4. Open that sucker in Designer (Notepad++) and find the <MainXSLLink> XML tag - it should be Line 69. Replace it with:
    • <property name="MainXslLink" type="string" >/Style Library/XSL Style Sheets/EditedStyles/ContentQueryMain.xsl</property>
    • If you want to be fancy, you can replace <ItemXSLLink> as well. It's not as important, because it simply provides a list of item styles for your site as a whole, where the MainXSL is a control document that dictates how all your CQWP display.
      • Don't fuck with that. Really.
    • <property name="CommonViewFields" type="string">Author, Text;</property>
  5. Save that webpart and put it into your development page. 
    • I like to set a new title, limit the items displayed to 5 for testing purposes.
  6. Open your new EditedStyles/ItemStyle.xsl in Designer/Notepad++
  7. Add the Debug style because you'll be wanting it.
  8. Check in everything and publish major versions of them, or else nothing will change and you will be mightily confused.
  9. Reopen  EditedStyles/ItemStyle.xsl and add this to it:
  10. Publish that.
  11. Go to your content editor webpart and edit its properties to be the table generator. It should be displaying your author, the date the thing happened, and a link to the file's title.

You have now stripped off the reporting privacy of anyone who ever uploaded a thing to their corporate intranet. The HR department can see _all_. So can you! Someone probably programmed this in C# once! But it wasn't you! And now you've reproduced their work except sort of slow and front-end style.

Congratulations! We're part of the problem.

Helpful Link:
http://sharepoint.stackexchange.com/questions/55128/remove-li-wrapper-from-content-query-web-part-contentquerymain-xsl

Helpful Link #2:
Here's some stuff from Heather Solomon:
New blog: http://blog.sharepointexperience.com/
Evidence of smarts: http://blog.sharepointexperience.com/2012/03/introducing-the-magic-data-view-builder/

Wednesday, July 3, 2013

Force Infopath Form to Open in Browser

Approval workflows are tricky and fragile and counterintuitive, and a lot of what I do on the daily is customize them to get around that issue. I repair issues like how they don't approve content but instead set an approval on a whole new unrelated field, or how when you set them up on Infopath forms, those forms show up inside whatever damn application they please regardless of even system-wide settings that are clearly tickyboxed to "Open In Browser, Not Everyone Has Or Uses Infopath."

Tricky.
  1. Open Sharepoint Designer.
  2. Open the offending workflow.
  3. Open the workflow within that workflow that contains the renamed out-of-the-box Approval workflow.
  4. Tricky.
  5. Click "Change the Behaviour of an Individual Task."
  6. Find the one that sends an e-mail to a Task Approver.
  7. In the first line of the utterly useless bullet points is something that, nominally, will allow people to open a form for review.
    • It is not a form for review, it is a portal to a severe system lockup.
  8. Change the link from whatever nonsense it is using to
    [%Current Item:Encoded Absolute URL%]?OpenIn=Browser
  9. Celebrate, as this actually works.
Now your infopath document-style XML form opens in the browser for all your users who have InfoPath installed but not the system resources to run it. Good day!