Quick and Easy: Use jQuery to Set A Text Field’s Value on a SharePoint Form

I started playing around with jQuery yesterday.  I’ve been wanting to do this for a long time, ever since Paul Grenier started writing his series about jQuery for End Users at the venerable www.endusersharepoint.com web site.  As I use it, I hope to add a series of “Quick and Easy” posts like this one.  This post describes how to set a known text field’s value to anything you want.

In this scenario, I have created a custom list whose “new” form looks as shown:

image

This is the new form for a custom list with the default Title column and two list columns (not site columns; I don’t think it should make any difference).

The objective is to assign an arbitrary value to the field, “DefaultMeFieldNoSpaces” (you can tell I’m a bit of a coward with the “no spaces” thing going on, but I do spice it up at the end of this article).

This bit of jQuery worked for me:

<script type="text/javascript">

  $(function() {

    $('input[title=DefaultMeFieldNoSpaces]').attr(
        {value: 'You are in a twisty maze of passages, all alike.'});

  });

</script>

 

As I understand it this bit of jQuery is saying, “find me any input tag whose title = DefaultMeFieldNoSpaces.  Then, set all of their values to a famous phrase from an old computer game.”

Since there will only be one field on the form with a title equal to “DefaultMeFieldNoSpaces” we are assured of assigning a value to that field and no other.

What about a field whose name has spaces in it?  It’s nearly the same:

<script type="text/javascript">

  $(function() {
     $('input[title=Assign Field With Space]').attr(
        {value: 'You are in a twisty maze of passages, all alike.'});

  });

</script>

 

I think this is a fairly safe approach, meaning that we should be able to find the field that we want and only the field we want.  If you look at the HTML SharePoint is giving us, it’s sort of messy:

<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="DefaultMeFieldNoSpaces"
class="ms-long"
/>

“title” stands out as a recognizable and hopefully unique attribute to help us identify the specific column to which we want to assign our arbitrary value.

This is a foundational concept.  Setting a field in an arbitrary way like this isn’t going to win any awards.  However, if we want to do more interesting form level stuff (which all of us always want to do, of course, right after we finish washing the dishes), like change the value of “field b” automatically based on the value of “field a”, we (I) need to learn these things.

I think our best chance to get a real useful value here is via the title, at least for text fields.  There may be a better, more reliable approach.  If I find it, I’ll update this post.  If you know a better way, please leave a comment.</end>

</end>

Subscribe to my blog.

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

SharePoint Demonstration: Leverage SharePoint to Build a Vertical Business Application

[Note: I want to straight away say that I have a financial interest in the desired outcome of this demonstration, which I mention in the interest of full disclosure, etc.  This is actually the first time I’ve ever blogged about an event where I stand to benefit personally in this way.]

This web demonstration takes place Thursday, 06/04 at 12:30 EDT, ending at 1:30PM EDT.

In cooperation with my excellent business partner, Integrated Systems and Services Group (ISSG), I have been working to develop a vertical business application using SharePoint as the platform.  In this case, we’re building an application that serves the needs of manufacturers that make customized product for their customers.  In these cases, a great deal of collaboration needs to take place between the customer and the manufacturer.  There’s also a great deal of collaboration required between different groups within the manufacturer, including sales, engineering, research and development, legal and other groups.

The demo is going to show an application that facilitates that kind of collaboration, along with a discussion on how all of those collaboration bits need to integrate with a backend ERP system.

Lastly, this isn’t going to be a SharePoint demo.  This is a demonstration of a solution for a specific niche problem that happens to use SharePoint as the platform.

So, why would you bother to sign up and see this demo?  I don’t expect too many readers of my blog to be all that interested in a solution for make-to-order manufacturers 🙂  Your take-away would be the concept itself – using SharePoint purely to deliver a business solution without regard to SharePoint itself.

If you’re interested, please sign up here(https://www323.livemeeting.com/lrs/8000043750/Registration.aspx?pageName=skmqfwbr5smmlx20).

</end>

Subscribe to my blog.

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

You Can Pry SharePoint Designer From My Cold, Dead Hands

My latest article is up at www.EndUserSharePoint.com.  I wrote about SharePoint Designer, End Users and the outline of a strategy that End Users might try and follow in order to demonstrate competence and build trust around this tool.

The comments are more interesting than the article itself.

Check it out.

</end>

Subscribe to my blog.

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

Technorati Tags: ,

Efficiently Follow Microsoft SharePoint (and Other) SharePoint Forums

I have been following MSDN forums for well over a year (and possibly almost 2 years at this point) and every now and then I hear from someone how “hard” it is to do that.  I find it quite easy and thought I’d share my “technique”.  This technique also works for www.endusersharepoint.com (http://www.endusersharepoint.com/STP).

Taking MSDN as an example, I first go to standard forum page such as the General Questions for SharePoint main page here: http://social.technet.microsoft.com/Forums/en-US/sharepointgeneral/threads

You should right away notice that the forums are RSS enabled, as shown:

image

I’ve been using Google Reader for managing my RSS feeds for a long time now (www.google.com/reader).  I go there, add the RSS feed for the forum and now I’m getting all new forums posts via RSS.  My Google feeds for SharePoint forums look like this:

image 

Google provides me a nice view of the posting itself:

image

And finally, Google lets me use the keyboard to scroll through the postings in the forums this way.

I can quickly scan through posts and focus just on those I feel I can make a useful contribution.

Alerts close the loop.  Updates to posts don’t come through RSS (though I think they used to a long time ago).  However, if I post a response to a forum posting, the forums alert me via email and IM that someone responded in turn.  Or, if I can’t make a useful contribution but I want to know what others have to say, I can drill into it and explicitly request alerts when others do respond.

In an hour or less you can set this process up and and in a week of regular use, learn the various keyboard tricks and shortcuts so that this becomes second nature.

I use the exact same technique for End User SharePoint.Com’s “Stump the Panel” forums.  This is their RSS feed: http://www.endusersharepoint.com/STP/rss/.

Forums are an awesome way, possibly the best way short of direct personal experience, of learning the product and getting a nice survey of how the world, at large, uses SharePoint.  Give it a try!

</end>

Subscribe to my blog.

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

Technorati Tags:

Use Custom Lists for More Effective Workflow Auditing

I’ve reorganized my life a bit and found some time to submit an article to www.endusersharepoint.com.  My latest article is up here: Use Custom Lists for More Effective Workflow Auditing (http://www.endusersharepoint.com/?p=1658).

This is the opening ‘graph:

SharePoint Designer workflow doesn’t give us a lot of visibility into what’s happening with our workflow solutions.  And, the visibility that we do get is hampered by a relatively poor interface and 60 day time window.  This 60 day window can be a major disappointment to new SharePoint Designer users because it’s not advertised by the tool itself.  It’s not at all uncommon for someone to fire up SharePoint Designer, create a workflow solution that leverages the “Log To History List” action…

The problem is that after 60 days, any messages that you create this way are deleted from the workflow history list!  After a bit of teeth gnashing and “what were they thinking?” arguments, the bottom line is this: it happens and it needs to happen.  The question is, how can we get around it?

The official answer is to rely upon SharePoint’s built-in auditing feature.  From an end user’s point of view, however, that’s very weak in WSS and not much better in MOSS.  Fortunately, we can still leverage the familiar SharePoint Designer tool to create a durable workflow history and audit trail which is an order of magnitude more useful to boot.  Here’s how.

I describe how to create a more friendly and useful audit solution for declarative workflow created in SPD. 

I was inspired to write this article from a recent project for a client that had developed nine technical SPD workflows in support of one logical business process.  Assuming for now that nine is a reasonable number, it was certainly a challenge to debug it or view the overall status of the process in one simple view.  Each of these separate technical workflows has its own independent workflow history list and that’s just not manageable.  I was able to combine all of them into a single audit list using the technique I describe on the site.

Check it out.

</end>

Subscribe to my blog.

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

Bamboo Calendar Interacting with SharePoint Causes “An unexpected error occurred”

Today, I’ve been working in an environment that uses a Bamboo calendar web part for some improved collaboration.  This a standard medium/small farm with two load balanced WFEs, a “application server” for indexing and InfoPath and a clustered SQL back end.

The client installed some disaster recovery software onto one of the WFEs and that resulted in a broken WFE for a specific site in the site collection.  Whenever load balancing pointed at the affected WFE and that site, users saw a largely blank white screen with the sentence “An unexpected error occurred”.  No other info showed, just that sentence.

They asked me to look at it.  I easily reproduced the problem and then added a ?contents=1 to the end of the URL.  This is how I learned they were using the Bamboo web part.  I went back to the page and now, suddenly, it showed me a nice orderly error message:

 

image

I don’t know what was happening or what I did to get the controlled error message to display other than appending the ?contents=1 bit of the query string. 

This is probably a very rare edge case but if you get that message, “An unexpected error occurred” go ahead and add ?contents=1 to the query string and see where that leads.

</end>

Subscribe to my blog.

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

Technorati Tags: ,

Griping about Windows Live Comment Control

I picked windows live spaces back in July of 2007 as my blogging platform.  For the most part, I don’t have any regrets and Microsoft certainly extends it over time (though I mainly find out about new features by accident).

My biggest complaint right now is blog spam.  This person / account (http://cid-82b0534bceed9881.profile.live.com/) (among others) frequently adds a lot of spam comments to my blog in the form of comments.  MSFT added a nice feature to show “recent comments” so at least I can fairly quickly identify them (whereas before, I had to go into each blog entry separately) and clean them up.  It’s still time consuming.

I wish that:

  1. MSFT would put some better filtering for spam.
  2. That I could block specific people from adding comments.
  3. Failing the above, I could more easily identify and delete spam.  Right now, I need to do it comment by comment and it’s slow, especially when some spam robot person/program adds 25 to 50 comments in one session.

If you’re a windows live user and have some useful tricks to share, I’d be grateful.

</endGripe>

Subscribe to my blog.

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

SharePoint Saturday Phenomenon Continues (plus, my slide deck)

I returned from Washington DC yesterday after attending the latest SharePoint Saturday.  What a remarkable event!  Continuing the tradition of other SP Saturday’s, it was very well run.  The environment, the overall organization, the flow, vendor area, food … all of it was terrific.

Of course, the best part is the content and I don’t think anyone was disappointed.

It’s really quite amazing to me how so many people are rousing themselves out of bed early on a Saturday to go and listen to people talk about SharePoint for 8 hours 🙂  Amazing.

Odds are, there’s a SharePoint Saturday event coming your way and if there isn’t, why don’t you start one?

I presented at the conference with the tongue twisting title, “Using the SharePoint Platform to Build Vertical Business Applications.”  You can get the presentation here: https://cid-1cc1edb3daa9b8aa.skydrive.live.com/browse.aspx/Public.  It’s not my usual sort of presentation and I had fun with it.  I’ll be giving this again in June at the North VA user group conference at the end of June.

</end>

Subscribe to my blog.

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

Governance is a Marketing Plan Too

The reason we spend so much time (or should, anyway) working out governance plans is because we want the SharePoint solution to be as effective as possible.  We want good infrastructure and rules to keep it humming and safe in case of disaster.  We want good security processes to both properly secure the environment but also make it reasonable to manage.  We want a good information architecture that will stand the test of time, ideally managing to survive a major organizational change in the company. 

To achieve that desirable objective, a governance document and plan can devolve into a bunch of “thou shall” and “thou shall not’s”, as in:

  • Thou shall not create SharePoint security group; use AD instead.
  • Thou shall not create folders in document libraries; use content types and views instead.
  • Thou shall create all document content types based off a specific custom base type.
  • Thou shall not create an information taxonomy based off today’s company org chart.

“Thou shall” and “thou shall not” certainly have their place in the governance plan.

A more successful governance plan will also have a strong marketing angle.  It should sell and justify itself to the maximum extent possible.  A truly successful governance plan relies upon the voluntary cooperation of all SharePoint users.  (There are fringe cases where community cooperation is not needed, such as when SharePoint is used by a very small number of tightly managed users; I’m sure you can think of others).  If the user community doesn’t buy into your governance plan then it will be partially successful at best.

I use that word “buy” deliberately.  The community will buy the governance plan if it’s fundamentally sound and you go to some effort to sell them on it.  Selling leads to marketing and that’s why I think that a governance plan should be considered a marketing plan too.  Convince your end users that they need to follow the governance plan and they will voluntarily follow it.  If you can get a critical mass of people following the governance plan then the plan’s benefits follow and you’ll have a stronger environment for it.

</end>

Subscribe to my blog.

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

Solution: Compiling MOSS Audience Adds No New Members

Bottom line: if you want to use a profile property in a rule for creating audiences, the property must be visible to “everyone.”

I was working with a co-worker yesterday and he was building out a MOSS audience based on a custom user profile property in MOSS.  In this case, the audience property is named “SITECD” and by convention, stores a 3 character code. He had defined the audience and a rule that said that if “SITECD equals ‘ABG’”, then include that user profile in the audience.

He set up a single user profile with that value and compiled the audience, but MOSS simply wouldn’t add that user.  I noticed that the privacy setting for that profile was set to “me only” (the most restrictive form) and I remembered reading somewhere that property profiles used in rules must be visible by “everyone”.  He made that change and that solved the problem.

The really funny thing about this is that I “remembered” reading about this.  It was nagging at me this morning for some reason and I realized that I had written a chapter in this book, MOSS Explained: An Information Worker’s Deep Dive into Microsoft Office SharePoint Server 2007, and that I covered this point in the very chapter I wrote :).  I would have thought that every word I wrote in that chapter would be seared into my memory.

Matt Morse writes this up in beautiful detail here and I referenced it in the chapter: http://blogs.pointbridge.com/Blogs/morse_matt/Pages/Post.aspx?_ID=50

</end>Subscribe to my blog.

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

Technorati Tags: ,