Author Archive

Cleaning Up the “1 to 5;#5#” number string from your Custom Survey Views.

Tuesday, July 21st, 2009

1. This is something I do after I have created a custom Survey View for reporting. For some reason, SharePoint pulls in the Rating numbers as “1 to 5;#5#” from the database. Using the native string functions in Designer, you can strip out this “1 to 5;#_#” junk  to leave just the raw rating number.
2. Open up Designer and open your Survey View page (ie. AllDataView.aspx) and highlight the first data cell UNDER the column name.

 
3. Right-click and select Edit Formula.

 
4. In the Edit the XPath expression, use the GUI (Select a function category) or match your field name to the function below. The field name will be something like so: @SomeField_x0001_x0002. The end result is a substring-before around a substring like so:  substring-before(substring(@SomeField_x0001_x0002, 9),'#'). Note that the Preview window will show your Survey Rating number as ‘5; 4; 3; …’ but Designer and your browser will show it as ‘5 4 3 …’. You may want to play with the start point and optional length in your string argument. 9 (above) or 15 worked for me. Try different combinations & see the results in the Preview window.

 
5. After you have added the string functions and see the rating numbers as ‘5; 4; 3; …’, click on OK.
6. Now you should see your Survey Rating numbers like so:

 

Survey pulling in URL Querystring Data with Hidden Fields(!!), Anonymous Access.

Friday, February 27th, 2009

This is a bit like "Part II" to my original post [ /ggill1970/archive/2008/01/18/pulling-in-querystrings-into-a-sharepoint-2007-survey.aspx ], but i wanted to document the entire process & how to get this to work.

Before I dig in, I wanted to mention something about Permissions & Anonymous Access that is very buggy w/ these Surveys. The Survey I am using is on an Extranet / Internet where Anonymous Access can be enabled. I only enable Anonymous access on the Survey where external customers come in (there is no real content except this on the site anyhow). This is under Settings | Permissions for this survey | Actions: Edit Permissions | (click "OK" for unique permissions) | Settings : Anonymous Access | Add Item, View Items. These settings are DISABLED when "Read Access: Only their own" is set under Settings | Advanced Settings. I was only able to use the Anonymous Access settings when "Read Access: All responses" was chosen.

  1. OK, so i set-up this Survey with a few questions & then added fields to pull in the URL Querystring data per my original post (linked above) and this Blog: http://blogs.msdn.com/sharepointdesigner/archive/2007/06/13/using-javascript-to-manipulate-a-list-form-field.aspx
  2. Using Jan's post, I customized the NewForm.aspx page with SharePoint Designer so that I would have more control later on when I began hiding certain fields: http://weblogs.asp.net/jan/archive/2006/11/06/Custom-Edit-Forms-for-SharePoint-2007-Lists.aspx . The critical steps for me were to delete the default WebPartPages:ListFormWebPart in NewForm.aspx and Insert the Custom List Form like so: Insert | SharePoint Controls | Custom List Form. Here are a few screen shots of this:

    (highlight WebPartPages:ListFormWebPart)


    (deleted WebPartPages:ListFormWebPart)


    (Insert | SharePoint Controls | Custom List Form)


    (List or Document Library Form)

    (Boom! WebPartPages:DataFormWebPart)

  3. Then I used the same javaScript from this Post to some / all the fields that pull in the Querystring data: http://www.cleverworkarounds.com/2008/02/07/more-sharepoint-branding-customisation-using-javascript-part-1/ . Excellent article; I used the JS script from the top of this page (there is another script mentionned at the bottom):
  4. <script language="javascript" type="text/javascript">
    _spBodyOnLoadFunctionNames.push("hideFields");
    function hideFields() {
       var control = getTagFromIdentifierAndTitle("Input","TextField","Requestor");
       control.parentNode.parentNode.parentNode.style.display="none";
    }
    </script>

Works perfectly and I decided to hide ALL of the form fields that pull in the URL Querystring data. This way the external customers only have to deal with (3) questions and there is less risk that the Querystring data will be changed or deleted. Then when the customers click on "Finish" I have all the important help desk ticket information that support reps can go through or report on later.

NOTE: Speaking of reports, I also have SSRS (SQL Server Reporting Services) reports working internally on Survey data and will do the same with these Extranet Surveys; more on this later. It works great and is much better that creating Custom Views that run slowly when hundreds of Surveys have been completed. See my original post on this here: /ggill1970/archive/2008/04/02/creating-custom-views-on-surveys.aspx . The SSRS reports I have built pull from a stored procedure & run lightning fast. 

 

Time Tracking Workflow: accumulate weekly hours into an actual (total) hours column.

Friday, August 15th, 2008

Hi All — Using SharePoint Designer, I just created this simple "time tracking" workflow I was tasked to develop. It turned out to be just a bit trickier than I anticipated to make this work, so I thought I would share. Smile The final piece needed to be a simple time tracking List (called Project Time Tracking) where I could have a project name with two tasks under each project name, Development and QA. The List has basically 6 Columns with data that needs to be shown in a View: Project Title, Task (Dev or QA), Estimate Hours, Weekly Hours, Actual Hours and Variance.  I was able to setup a Custom List pretty easily where the View Grouped the Project Title to show the Dev and QA Tasks grouped below it. Note that I gave Weekly, Actual and Estimate Temp default valuesof '0'. The Variance columns is Calculated where it Subtracts Estimate Hours minus Actual Hours.
  

The workflow comes in with the functionality I needed to accumulate and calculate Actual (total) Hours. This List needed to function like so: a Project Manager would come in and create the above structure for a Project, filling in Estimate Hours and leaving Weekly Hours blank (0). Then a Developer or QA person would come in and add the hours they spent each week on any given Task. Anytime the Dev or QA person added (or subtracted hours), this would be accumulated in the Actual Hours column. So if they come in and add 10 hours on week 1 then add another 5 on week 2, the Actual should show 15 and so on. Also, if they "add" -5, the Actual would drop down to 10. I wasn't sure what the limits of a Calculated columns would be here, so I immediately went with a short Workflow to get this done, using a TEMP column, Estimate Temp (previous) to store added Weekly hours. 

My Workflow logic is pretty basic:

  1. On this Custom List, automatically start this workflow whenever an item is changed (The PM would have already setup the Project Name, Tasks with Estimate Hours).
  2. If the Weekly Hours not equals 0, Then,
  3. Take the Weekly Hours number & copy it to the Estimate Temp (previous) column (This way I always had a copy of last weeks hours).
  4. Add Actual hours and Estimate Temp (previous) hours to equal a new variable.
  5. Overwrite Actual Hours with this new variable.

However, out-of-the-gate, this Workflow did not work correctly. SharePoint would process each step too quickly / simultaneously and the Estimate Temp (previous) hours would get skewed, then messing up the Actual number. I believe when the User inputted the new value and again by the Workflow…it was weird. So I had to slow down the Workflow to process the steps a little more deliberately.

The first thing I tried was Pause for Duration, but this too much too long as the lowest I could go was 1 Minute. Then the SharePoint Timer Job would take over (OWSTIMER.EXE) adding another 5 minutes. I thought about changing the "-propertyname job-workflow" to 1 minute through STSADM, but I didn't want to make global changes like this to the system before I tried a few other methods. The Wait for Field Change in Current Item worked perfectly. Here are a few screen shots of the finished Workflow with a few of the dialog box details and then the Project Time Tracking List with data added by a Developer.

Update item in Project Time Tracking:

then Update item in Project Time Tracking:

After adding 5 to Weekly Hours:

After adding 10 to Weekly Hours:

After subtracting 5 hours by entering "-5":

This could be improved because it calculates any time a record is updated (not only the weekly hours), but it works ok for something thrown together quickly. If i can find a method to run the Workflow ONLY when the Weekly Hours column is updated, this would work. Hopefully someone can use this same method to use temp columns to keep records of previous data. I was also thinking this could be done with JavaScript on the ASPX page, but this seemed easier & faster.

Workflows / SP1: Automatic (new items) Workflows are not Starting when logged in as Service Account!

Wednesday, July 30th, 2008

WOAH…this took all day to figure out. I found this KnowledgeBase acticle that details a real Workflow killer if you are working / logged in as your SharePoint Service Account: http://support.microsoft.com/kb/953289 ( A declarative workflow that is configured to start automatically when e-mail enabled items are created does not start automatically after you install Windows SharePoint Services 3.0 Service Pack 1). This problem occurs because a security fix in Windows SharePoint Services 3.0 SP1 prevents declarative workflows from starting automatically under the system account. E-mail enabled list items are always created under the system account.

The fix was to log out as the service account (OWSTIMER.exe is running under this account on the MOSS server) and login as myself where i have Full Control or Contribute. Enough rights to start a Workflow.

I found this issue building custom Task email alerts with SharePoint Designer. They just would just not start when new items were added / updated…but i believe could be manually started. I would go into the Task list setting and set "Send e-mail when ownership is assigned?" to No and then build a simple Workflow that would send a custom email template to 'Tasks: Assigned To' when an new item was added. The email template is the same type of Microsoft alert formatting (HTML/CSS) found in this article: Create Custom E-mail Alert Templates for SharePoint Workflows . This also broke my secondary Workflow settings (coming from a Document Library) where I am setting a Due Date to the Tasks.

Creating custom Views on Surveys

Wednesday, April 2nd, 2008

Creating Views on Surveys is something that does not work out-of-the-box and this functionality is nowhere in the GUI. However, I was able to use a URL "hack" to get this done; one to Create the View and one to Edit it. Then I used Designer 2007 to add certain Columns; the 1 to 10 scale data types would aways be hidden. So I had to use Designer to add them manually in XSLT View. This also gave me an opportunity to add Column Filtering to this data and remove the "#" signs (??) in the data, just leaving the number the User chose in the 1-10 scale for a question. See the bottom of this article, I will detail this in another Post. Also check out Paul's post mentioned at the bottom of this article, Customized views of a SharePoint Survey .

My main requirement here was reporting & SSRS wasn't yet set-up. And a bug in the "Export to Spreadsheet" led me to Views as a solution. The Export function was leaving out the datetime stamps for Created, Modified and similar. I believe a few other key pieces of Metadata. There are also other bits of functionality that are specifically disabled / don't work in Survey Lists. Content Types are not present. Then depending on how Advanced Settings are configured (specifically Read Access and Edit Access), Workflow and Alerts do not work correctly. For example, when you lock the Survey down to "Only their Own" (posts) you will get the error "You cannot create alerts for lists for which users can only read their own items." when you try to set-up Alerts for yourself/your group. With "Only their Own" enabled, Workflow will not function correctly and you will get "Error: {workflow name} failed to start, Workflow canceled: Workflow {workflow name} was canceled by {Username}". Ok, a little off-topic here…on to the View process.

Create a custom View in your Survey:

  1. Find the Survey List ID. I usually get this just by Viewing the Source on the Overview.aspx page. Near the top of the source, SharePoint gives you the List feed. Just search on listfeed.aspx. Then get this bit: /SiteDirectory/CS/IT/_layouts/listfeed.aspx?List=6071a4f7%2Db688%2D4e83%2D8895%2De53960bf1a58".
  2. Modify the "Create View" URL to add the Survey's ID. Add in your Survey ID, making sure to swap out the URL encoded %7B to "{",left curly bracket and %7D to "}", right curley bracket. This will give you this much: http://moss-1/SiteDirectory/CS/IT/_layouts/ViewType.aspx?List={6071a4f7%2Db688%2D4e83%2D8895%2De53960bf1a58}
  3. Modify the "Create View" URL to add the Survey's Source Path. Then you just add the Link to your Surveys "All Responses" View. It would look something like this: http://moss-1/SiteDirectory/CS/IT/Lists/Test%20Views/AllItems.aspx . To complete the "Create View" URl like so: http://moss-1/SiteDirectory/CS/IT/_layouts/ViewType.aspx?List={6071a4f7%2Db688%2D4e83%2D8895%2De53960bf1a58}&Source=http://moss-1/SiteDirectory/CS/IT/Lists/Test%20Views/AllItems.aspx . Don't worry about the lack of URL encoding as this will happen once you go to this URL.
  4. Go to the "Create View" URL and choose a View Type. Choose All Responses. Standard View and the others never seems to show enough data.
    Create View
  5. Name your View and add Columns for display: From here, it is just standard stuff, although i would recommend selecting almost ALL of the available Columns as a start. 
  6. Review your new View (from the View dropdown).
    New View

Then Editing the View is the same process; you use an "Edit View" URL from the same site on a List. It makes sense to Bookmark/Save these links as I ended up Editing the custom View quite a bit. EDIT: I like Paul's method for Editing the Views, once they are created. See his post on Customized views of a SharePoint Survey . This got me thinking & it seems possible to use Designer to Copy/Rename the All Responses View and then Edit it with the GUI or Designer. 

In my next Post, I will detail how to add Columns in Designer on the View's ASPX page. Essentially, I needed to add the 1-10 question data type columns, massage the data (string manipulation) and turn on Column Filtering. The first step is to open the ASPX page, highlight the ListViewWebPart and Choose 'Convert to XSLT Data View'. More later…

MOSS 2007 STSADM: enumsites and backup syntax, ideas

Tuesday, February 5th, 2008

Just a quick post on some work I am doing migrating all the My Sites on my intranet. I was having a tough time outputting the enumerated sites to a text file & finally figured it out, so here is the syntax. My problem was that i was trying to use the -filename toggle instead of ">>", ugh:

Then once I had the list, I was able to massage the My Sites list for this type of thing as a big BAT file running Backups:

Last, I find this is a nice way to Backup the larger sites with timestamps nested around stsadm backup commands…outputted from a BAT file at the command line. This was good for me to estimate the time it would take for backups / restores in a Test environment in prep for the same thing in Production:

 

Pulling in Querystrings into a SharePoint 2007 Survey

Friday, January 18th, 2008

I had a small project in SharePoint 2007 where I needed to pull in Querystring variables from a URL into form fields in a Survey. In the environment here, Users send in Help Desk tickets through Remedy (Action Request System). When the request is complete/resolved, the ticket auto-closes 2 days later; sending the user solution details and a Link to the SharePoint Survey. The Survey is basically a Customer Satisfaction Survey, but we also needed to pull in and track things like Ticket Number, IT Group, Individual working on the Ticket, Category, Type, Item and Summary for reporting later…generally if the Survey response numbers were low or  unsatisfied, it was at the top of certain reports for followup. 

I worked with the Remedy Admin to build the Survey in SharePoint 2007 & once it was done, I gave him the Querystring variable names that i needed to be in the URL for him to populate programatically from Remedy. Then each User with a completed ticket got an email telling them their ticket would close in 2 days & prompted them to follow the link and fill out the Customer Satisfaction Survey. The link from Remedy looked something like this: http://moss/SiteDirectory/TheSite/Lists/IT%20User%20Survey/NewForm.aspx?num=HD00001&grp=ITISS-Backline&ind=John+Smith&cat=Hardware&typ=Laptop&itm=Video&sum=Need+assistance+setting+up+Video+conference+in+the+boardroom+for+Dave+Helfgott

I used Rob Howard's Blog article to get the Querystring manipulation with Form fields going: http://blogs.msdn.com/sharepointdesigner/archive/2007/06/13/using-javascript-to-manipulate-a-list-form-field.aspx. Great script! His article specs a Custom List, but it works just as well for a Survey (I will Blog later on how Surveys do not function like  traditional List in so many ways and my workarounds for all the limited functionality and other  bugs).

Ok, here is what my Survey looks like (with no Querystring  data) before modifying it in SharePoint Designer 2007:
 survey 1

I added this JavaScript block pasted below in red to the NewForm.aspx page using SharePoint Designer. I placed the JS in between a ASP:CONTENT tag near the bottom of the page like so: <asp:Content ContentPlaceHolderId="PlaceHolderTitleAreaClass" runat="server">INSERT-SCRIPT-HERE</asp:Content>.

There is probably a more elegant way to populate field values from Quesrystring vars, but i just copied/renamed the "setTextFromField" function like so "function setTextFromFieldName, function setTextFromFieldName2, etc." and then set up the Querystring vars like so at the bottom of the script: "setTextFromFieldName("Ticket Number", vals["num"]), setTextFromFieldName2("Ticket Summary", vals["sum"]), etc.".  NOTE in setTextFromFieldName how vals["num"] corresponds with the Querystring variable NewForm.aspx?num=HD00001 in the URL above and "Ticket Number" corresponds to the name you gave the form field column you created (technically when you created a new Question as a single line of text). 

So, this covers the 7 form fields I used with my 7 Querystring variables. In my situation, all 7 were "Single Line of Text" form field types, although (per Rob's article) you can populate all the typical SharePoint column types and their corresponding “identifiers” and “tagNames” listed here:  http://blogs.msdn.com/sharepointdesigner/archive/2007/06/13/using-javascript-to-manipulate-a-list-form-field.aspx

<script type="text/javascript"> 

_spBodyOnLoadFunctionNames.push("fillDefaultValues");

function getTagFromIdentifierAndTitle(tagName, identifier, title) {  var len = identifier.length;  var tags = document.getElementsByTagName(tagName);  for (var i=0; i < tags.length; i++) {    var tempString = tagsIdea.id;    if (tagsIdea.title == title && (identifier == "" || tempString.indexOf(identifier) == tempString.length - len)) {      return tagsIdea;    }  }  return null;}

function setTextFromFieldName(fieldName, value) { if (value == undefined) return;   var theInput = getTagFromIdentifierAndTitle("input","TextField",fieldName);theInput.value=value}

function setTextFromFieldName2(fieldName, value) { if (value == undefined) return;   var theInput = getTagFromIdentifierAndTitle("input","TextField",fieldName);theInput.value=value}

function setTextFromFieldName3(fieldName, value) { if (value == undefined) return;   var theInput = getTagFromIdentifierAndTitle("input","TextField",fieldName);theInput.value=value}

function setTextFromFieldName4(fieldName, value) { if (value == undefined) return;   var theInput = getTagFromIdentifierAndTitle("input","TextField",fieldName);theInput.value=value}

function setTextFromFieldName5(fieldName, value) { if (value == undefined) return;   var theInput = getTagFromIdentifierAndTitle("input","TextField",fieldName);theInput.value=value}

function setTextFromFieldName6(fieldName, value) { if (value == undefined) return;   var theInput = getTagFromIdentifierAndTitle("input","TextField",fieldName);theInput.value=value}

function setTextFromFieldName7(fieldName, value) { if (value == undefined) return;   var theInput = getTagFromIdentifierAndTitle("input","TextField",fieldName);theInput.value=value}

function fillDefaultValues() {  var qs = location.search.substring(1, location.search.length);  var args = qs.split("&");  var vals = new Object();  for (var i=0; i < args.length; i++) {    var nameVal = argsIdea.split("=");    var temp = unescape(nameVal[1]).split('+');    nameVal[1] = temp.join(' ');    vals[nameVal[0]] = nameVal[1];  }    setTextFromFieldName("Ticket Number", vals["num"]);   setTextFromFieldName2("Ticket Summary", vals["sum"]);  setTextFromFieldName3("Group", vals["grp"]);  setTextFromFieldName4("Individual", vals["ind"]);  setTextFromFieldName5("Category", vals["cat"]);  setTextFromFieldName6("Types", vals["typ"]);  setTextFromFieldName7("Item", vals["itm"]);}

</script>

OK, that is basically it once you save the NewForm.aspx page. You can test out the script out with dummy Querystring variables. The example URL i showed at the top of this would display like the graphic below. Some of the form fields you are not seeing are Group, Individual, Category, Types and Item at the bottom of the Survey. Just the way everyone wanted this laid out. Then when Users hit Finish on the Survey, it writes these populated Querystring variables to the Database as it should. Part 2 of Pulling in Querystrings into a SharePoint 2007 Survey deals with Views, Exporting the data & other Reporting options. Not to mention issues with Content Types, Workflow and Alerts that are present with Surveys, ugh.
survey-2

Instructional Materials for SharePoint 1970.

Thursday, January 10th, 2008

But seriously, welcome to my 1st Blog post on SharePoint 2007 (I will talk about my fascination with the year 1970 later). Cool I have a bunch of stuff on 2007 Survey development, tips, bugs, views, reports and similar. If you haven't done much with them yet, I have found them to be a huge challenge as they seem to act like a Custom List with disabled functionaliy. More on this later.