SharePoint Shop Talk Open Q&A Session Thursday 08/13 @ 12:30 PM EDT

Arcovis will be hosting our second “SharePoint Shop Talk” session this Thursday at 12:30 PM EDT.  Show up with your SharePoint questions and we’ll do our best to entertain you with banjo jokes, smart but harmless put-downs of our fellow panelists and maybe even answer a question or two.  This week’s “official” panel includes yours truly, my Arcovis partners (Natalya Voskresenskaya and Harry Jones) and Laura Rodgers (of twitter & EndUserSharePoint fame).  Bob fox threatened to join too, but I don’t take that too seriously.  Last time, we had a great level of audience participation which blurred the line between panelists and attendees and I expect the same will happen Thursday.

This event is co-sponsored by Integrated Systems and Services Group (www.issgroup.net).

Please register here: https://www323.livemeeting.com/lrs/8000043750/Registration.aspx?pageName=9xrzxfs9x34sb0sm

If you have questions that you’d like us to take, just dial into the call and ask it.  If you want us to think about it first, send us an email or leave a comment here.

See you then!

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

Pre-existing Conditions: SharePoint Alert Templates to the Rescue (?)

One of my clients worked with a previous contractor to build out a small but useful HR application for the enterprise.  That contractor used SharePoint Designer to implement the workflow portion of the solution.  It’s a bit of a mess.  For instance, there are nine SPD workflows in support of a single logical workflow process and up to five of them may fire simultaneously at any given time given the right conditions.  It’s not easy to debug 🙂

My customer has a number of still-outstanding requirements, one of which is to generally provide more context when the system sends out email alerts – both in the email itself as well as associated task forms.  As SPD workflow implementers know, the “collect data from user” SPD action actually creates a task with a custom content type.  When we use that action, we don’t get to specify much.  We can prompt for some values (e.g. “approve” or “deny”) and we can specify a hard coded value in the title and description.  That’s about it.

My customer’s requirement is two fold:

  1. When SharePoint sends an email about a task assignment, include a lot of information about the task in the email body.
  2. More importantly, by far – when the user clicks on the task link in the email, the task form should have all the information the approver needs in order to make his/her approve or deny decision.  Right now, the manager needs to click on the item link itself to drill down into the underlying details and no one likes that.  You have to click in the email.  Then you need to click a sort of obscure link on the task item.  Then you can look at the underlying data (an InfoPath form in this case).  Then you click back/back, etc.  Everyone hates it.

I’ve inherited this somewhat messy technical solution and I want to make changes in the least intrusive way possible.

The approach I’m taking right now is to create a custom alert template.  You can read about that here.  The flow works like this:

  • SPD workflow runs.
  • At some point, it assigns a task to a manager.
  • SharePoint system automatically sends out an alert to that manager.  This is not part of the SPD workflow but rather “what SharePoint does.”  (The SharePoint timer service, I believe).
  • A custom alert handler is invoked in favor of the standard alert process (following magic rules as described in the above referenced article).
  • When my custom alert handler runs, it generates a beautiful email.  More importantly, since it has the task in hand, it also decorates the actual task with all the context information necessary to meet the business requirement.
  • The user gets the email and it’s full of useful context information.
  • User clicks on the task link and the task itself is full of useful context information.
  • Everyone goes home to have watermelon and ice cream.

I did a quick POC and it works well in a lab environment.  I get my custom email alert as expected.  I also get to update the task description and title itself.

The only tricky bit, so far, is to avoid a situation where the alert updates the item, triggering another alert.  This doesn’t worry me.

Looks promising so far…

The great thing about this is that I don’t need to muck about with any of the existing SPD workflows.  They are blissfully unaware that an alert handler is “IIZ RUNNIN IN DA BAKGROUND, DECORATIN TEH TASK LIST WIF MOAR CONTEXT”.

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

Live SharePoint Q&A Session Thursday 07/30/09 @ 12:30 PM EDT ending 1:30PM EDT

Update: The format for this is basically a conference call with a couple of PPT slides to set the stage.  We have a SharePoint environment on stand by to fire up in case it helps out, but this is mainly people talking out loud.  There will be opportunities for follow up by email.

Going back to my first ever SharePoint conference, just over a year ago, I’ve been struck by how terrific a live Q&A session can be.  The conference organizers had put together a sort of ad hoc group of “experts” (i.e. people who were hanging around and weren’t afraid of looking to silly up on stage) to answer any questions that came from the audience in the room.  It was in my head back then, and periodically since then, to host a similar session but do it on line and the phone.  I don’t think it can be as good as an in-person Q&A session, but I think it could be pretty cool.

I finally got around to it and next Thursday, 07/30, my company (Arcovis) and business partner, Integrated Systems and Services group, will be hosting a Q&A like that.  I’m hoping to do these regularly, as often as weekly. 

This inaugural session will probably be a little bumpy, but the concept is this:

  • If you have questions that you’d like to have answered during the session, just show up and ask.
  • If you want, you can email the question in advance.

We plan to spend the first half of the Q&A on emailed questions and then open it up to anything that anyone asks after that.

The session takes place on Thursday, 07/30 starting at 12:30 and ending at 1:30 PM EDT.

If you’re interested, kindly register here: https://www323.livemeeting.com/lrs/8000043750/Registration.aspx?pageName=pxlsd9fpsm2md7h9

The panel will include me and other SharePoint luminaries.  You’ll have to sign up to find out who they are 🙂

If you’d like to be one of those luminaries for a future Q&A session, let me know.

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

Technorati Tags:

Embed Developer Notes Inside Your InfoPath Forms

I’m still living in InfoPath Forms world and I needed to make one of those “small” changes to a form that, unfortunately, breaks a naming convention I adopted with it two weeks ago.  I thought to myself, “someone is going to look at this thing a year from now and say, ‘What was Paul thinking?  By Jove, his naming convention makes no sense!”

I realized that I could create a view on the form for this and then, once again, realized that I could have been doing something like this all along.  I added a “Developer Notes” view to the InfoPath form as such:

image

I’ve configured the form so that users can’t get to that view and therefore, it’s only visible with the InfoPath client in design view.  Now I feel a little inoculated against some future unknown developer looking at my form and thinking bad thoughts about me.  Phew!

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

Technorati Tags:

Managing InfoPath Views

I seem to go through InfoPath phases where, out of the blue, I’m crafting a bunch of forms.  My fingers learn how to use the tool well and then I go through nine month drought and have to learn it all over again. 

I’m in the middle of an InfoPath phase and I’m creating InfoPath forms with a lot of views. One thing you probably notice is that the InfoPath 2007 client shows views in alphabetical order.  This is a real nuisance some times.  My best technique these days is to prepend a number to the view name so that they always show in the order I want, as illustrated here:

image

I wish I had been doing this all along. 

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

Technorati Tags:

InfoPath Form Sevices, Forms Based Authentication (FBA) and Unique File Names

I’ve been working on some InfoPath forms this week in MOSS in an FBA environment and learned, when I went to deploy the forms to a production environment with an FBA zone that the username() function function does not work.  I was using it to generate unique file names.

Well, that function doesn’t work in an FBA environment (at least, not out of the box).  And, upon reflection, using username in the way I had planned wouldn’t have guaranteed a unique file name in any event.

My solution was to use the now() function and a rule that fires on loading of the form.  I assign the file name to data element when it’s blank:

image

image

The advantage of this approach is that the file name is set only once.  (I don’t show it in the screen shot, but put a condition on the rule to only fire when “myFilename” is blank).  I used to set the file name at the data source level.  Typically, I would do something (bad) like this:

image

The problem with that is that if user A opens the form on Monday and the user B changes it on Tuesday, you’ll end up with two different forms since two different users saved it with different user names.

So, as annoying as FBA can be in general and with InfoPath in particular, it made me re-think a small but really important technical detail and approach that I wouldn’t have done otherwise!

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

Technorati Tags:

Securing SharePoint List/Document Library Views Seems (sort of) Possible with jQuery

This is another post in my on-going series on how to use jQuery with SharePoint.
If you want to learn more about jQuery, I highly recommend: jQuery in Action by Bear Bibeault and Yehuda Katz.

One of the first things I thought, once I started to play around with jQuery, was whether we could use it to secure a SharePoint view.  The answer is “no” (or at least, I’m not claiming it’s possible).  However, it is certainly possible to make it difficult for people to see a particular view. 

I started with my sandbox environment when working on this.  I wrote about that environment here: Quick and Easy: Create Your Own jQuery Sandbox for SharePoint.  

To “secure” a view, follow these steps:

  1. Create a view you want to secure.  I did that and called it “Secured View”.

    This is what it looks like when it’s not “secured”:

    image 

  2. Add a content editor web part to the view’s page using the trick described in the sandbox article (i.e. add “PageView=Shared&ToolPaneView=2” to the URL).
  3. Figure out  your SharePoint _spUserId by following these crazy steps, believe or not:
    1. Log into your SharePoint environment.
    2. In the web browser’s address field, type: “javascript:alert(_spUserId”).
    3. Record the result (it’s “13” in my case).

      image

  4. Add the following javascript to your CEWP in code view:

    <script
        type="text/javascript"
        src="../../jQuery%20Library/jquery-1.3.2.min.js">
    </script>
    
    <script type="text/javascript">
      $(function() {
    
        alert(_spUserId);
    
        var theSecuredView = $('iframe[FilterLink*=Secured%20View]');
    
        if ((theSecuredView.length > 0) && (_spUserId == 13))
          $('iframe[FilterLink*=Secured%20View]').parent().parent().parent().html("<tr bgcolor=red><td>No view for you!</td></tr>");
      });
    
    </script>
    

I’ve included that alert(_spUserId) line in there to demonstrate how this is not really a “securing” a view, but simply making it more difficult to see.  More on that in a moment.

Basically, jQuery is looking for an iFrame on the page who has an attribute that contains “Secured%20View” in its value.   Once it finds it, we check to see if the current user is “13”.  If it is, we walk up the DOM to a <TR> tag (which I figured out by viewing source and tracing it) and then replacing that TR tag with my message. I really don’t know how robust this is (I’m very suspicious, in fact), but it worked in my sandbox.  If I find a better way, I’ll blog about it. This is the result:

image

I click the OK button and the data is replaced with a big red message:

image

As you can tell, the way I’ve implement this “security” solution is to allow the web part to render itself.  After it finishes, I overwrite its content with my “No view for you!” message.

Despite the fact that it’s not really a “secured’” view, it’s potentially useful and with some clever work, it may eventually be securable in a more formal sense.  The fundamental issue is that the client is getting all the data and then, only after it gets the data, it wipes it out.  If the client is getting the data, a clever user can prevent the jQuery from running at all and see what he/she wants to see.

There are other drawbacks.  This “security” approach is based off a _spUserId.  We’d want to really secure based on the full SharePoint security model, or at least by user name.  That becomes progressively harder, but I see some good stuff written on this subject, so I’m hopeful there’s a good answer to that problem.

The list of views themselves should be trimmed, if possible.  I haven’t tried to figure that out.  I assume it’s possible, but doesn’t really solve the fundamental security issue because someone could still just type the URL of the view they want (if they knew it).  However, trimming makes sense.  It’s a good usability feature and it helps to obfuscate things.  If an end user doesn’t know that the view event exists, they probably won’t try to use it.  Sometimes, that’s good enough.

With luck, I’ll have more to write on this subject over time.

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

Quick and Easy: A Better Way to Use jQuery to Hide a Text Field on a SharePoint Form

This is another post in my on-going series on how to use jQuery with SharePoint.
If you want to learn more about jQuery, I highly recommend: jQuery in Action by Bear Bibeault and Yehuda Katz.

Previously, I wrote about how to use jQuery to locate and hide a text field on a form.  I didn’t care for the specific approach (I was chaining parents – that’s simply isn’t done these days, at least in families of quality). 

When I first started to think about it, I knew I needed to find a <TR> to which I could invoke the hide() method.  My early effort to find the correct <TR> was something like this:

$('tr:has(input[title=Hide Me!])');

The problem with that is that it would find every <TR> tag that had any parent relationship to the Hide Me! field, even if Hide Me! is nested many levels deep in <TR>’s.  It turns out that on my sandbox form, that expression finds 9 different TR’s who have Hide Me! as a child somewhere in its DOM tree.  I realized that I could walk back up the tree from the input field itself, so that’s how I ended up abusing parents, but it didn’t sit well with me.

I gave some thought to this and one of the things I read finally made sense: I could use the not() method to trim out <TR>’s I don’t want in my wrapped set.  That led me to this:

$('tr:has(input[title=Hide Me!])').not('tr:has(tr)').hide();

The first bit finds all the <TR> tags that have the Hide Me! field anywhere in their own hierarchy.  It then strips out any <TR> that also have a child <TR>.  This leaves us with a single <TR> that:

1) Has no <TR> child records

2) Does have the input field as child. 

We can then apply the hide() method to the resulting set and we’re done.

I’m still a bit nervous about this, but not as nervous as chaining parents.

I don’t know if this is a best practice or not.  There may be a more appropriate way of identifying just the <TR> that we care about in a SharePoint form.  If you know, please post a comment.

</end>

 

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

Quick and Easy: Use jQuery to Hide a Text Field on a SharePoint Form

This is another post in my on-going series on how to use jQuery with SharePoint.
If you want to learn more about jQuery, I highly recommend: jQuery in Action by Bear Bibeault and Yehuda Katz.

UPDATE (already!): I did think of a better way to locate the <TR> tag I want to hide and wrote about it here.  You may still find this article interesting anyway so I’m leavnig it up.

I want to hide a text field, “Hide Me!” as shown:

image

The following jQuery does the trick for me:

<script type="text/javascript">

  $(function() {


    $('input[title=Hide Me!]').parent().parent().parent().hide();

  });

</script>

 

The code is saying, “find me all input fields whose title = Hide Me!.  Then, get its parent and then next parent and the *next* parent (phew!) and invoke the hide() method on that thing, whatever it happens to be.

I figured out that parent structure by viewing the HTML for the form that SharePoint created as shown:

<TR>
    <TD nowrap="true" valign="top" width="190px" class="ms-formlabel">
        <H3 class="ms-standardheader">
            <nobr>Hide Me!</nobr>
        </H3>
    </TD>

    <TD valign="top" class="ms-formbody" width="400px">
        <!-- FieldName="Hide Me!"
                 FieldInternalName="Hide_x0020_Me_x0021_"
                 FieldType="SPFieldText"
        -->
        <span dir="none">
            <input
                name="ctl00$m$g_bdb23c2c_fde7_495f_8676_69714a308d8e$ctl00$ctl04$ctl02$ctl00$ctl00$ctl04$ctl00$ctl00$TextField"
                type="text"
                maxlength="255"
                id="ctl00_m_g_bdb23c2c_fde7_495f_8676_69714a308d8e_ctl00_ctl04_ctl02_ctl00_ctl00_ctl04_ctl00_ctl00_TextField"
                title="Hide Me!"
                class="ms-long" />
                <br>
        </span>


    </TD>
</TR>

 

This picture shows the same, but marked up with the parents:

image

The first parent (1) is a span tag.  Span’s parent (2) is a TD tag and then finally we get to the real parent I want to hide (3) which is the TR tag itself.

This is a pretty terrible approach I think because it’s extremely dependent on the very specific structure of this form.  When SharePoint 2010 comes out, this whole structure could change and break this approach.  What I really want to do is craft a jQuery selector that is along the lines of “find me all the TR’s (and only TR tags) that have somewhere in their child elements an input field whose title = Hide Me!”.  I starting from the bottom and moving up.  Assuming I figure this out, I’ll post an updated “quick and easy’ post.

 

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

Quick and Easy: Create Your Own jQuery Sandbox for SharePoint

This is another post in my on-going series on how to use jQuery with SharePoint.
If you want to learn more about jQuery, I highly recommend: jQuery in Action by Bear Bibeault and Yehuda Katz.

Getting started with jQuery in SharePoint is surprisingly easy (to me).  (I do have serious questions about a “best practices” approach to deploying these things to production, but that’s for another day).  I’ve just started playing with this technology and to that end, I created a sandbox environment to use.  If you’re looking to get started with jQuery, you may find this approach useful.

1. Create a Blank Site

Create a blank site somewhere in your site and call it something clever like “jQuery Sandbox”.

2. Download jQuery

You can download the jQuery javascript library from here: http://docs.jquery.com/Downloading_jQuery

Save that to to your desktop.

I have been using the “minified” version.

3. Create a SharePoint Document Library

In your sandbox site, create a document library. 

4. Upload the jQuery Library to SharePoint

Access the doc library you just created and upload the jQuery library.

5. Create a Custom SharePoint List

I’ve started with a custom list because I want to muck about with standard SharePoint forms.  You could also create a page in a pages library or web part pages and probably a lot of other places. 

Add some columns to the custom list so that you have something to run jQuery against.  My initial objectives were to:

  1. Hide a field.
  2. Assign a value to a field.

With that objective in mind, I added two text fields.  Over time, I’ll be playing with links, images, lookups, etc. 

6. Modify the NewForm.aspx Web Part Page and Add a Content Editor Web Part

This is a little black magic-ish , in that it’s a new concept to me.  I first learned about this from Paul Grenier, SharePoint jQuery Superstar, at his CodePlex project site: http://spff.codeplex.com/

Follow these steps to add a CEWP to the same page that shows NewForm.aspx for any custom list:

  1. Access the custom list and click New.
  2. Append the following to the URL: PageView=Shared&ToolPaneView=2

That will transform your boring vanilla data entry form from something like this:

image

To this:

image

Add the content editor web part to the page.

7. Write Your First jQuery Code

Open up that CEWP in the code view and add the following:

image

Here’s the actual code if you want to copy/paste:

<script
    type="text/javascript"
    src="../../jQuery%20Library/jquery-1.3.2.min.js">
</script>

<script type="text/javascript">
  $(function() {

    $('#resultsID').html('There are ' + $('a').size() + ' a tags tags on this page.');

  });
</script>

Result:
<div id='resultsID'></div>
/result

Note that the first <script> tag is referencing the actual jQuery library.  Presumably, these things change over time, so you’ll want to make sure you a) use the right name and b) point it to the correct SharePoint document library.

Bask in the Glory

If you did it correctly, you’ll see a result similar to the following:

image

Wrapping Up

This isn’t the only way to get started, but it’s quick, easy and isolated from your existing SharePoint environment. 

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin