Slinger's Thoughts

January 21, 2008

Custom workflow in SharePoint Designer doesn’t quite work right. Some help?

Filed under: SharePoint — Tags: , , , — slingeronline @ 1:31 pm

In my search around the web for SharePoint insight, I came across a blog post on SharePoint Beagle, about a custom training classes scheduling solution.  It’s very elegant, and would work perfectly.  If it worked. For reference the tutorial by Natalya Voskresenskaya is here. I would have e-mailed her directly for the solution, but I can understand her not wanting to post her contact information online.  So I follow the tutorial as word for word as I can. Which I will detail below. (Hopefully she isn’t too upset with me for posting this, but it is a fantastic solution, and I would like to get it to work.) So, I create a new site in my site collection. I set it to the Team Site template per her recommendation, and I name it “training.” I create a calendar list named “Classes.” I don’t create a workflow to notify any trainers because so far I am the only one.  I add one column to the list labelled “trainer” and set that to allow only “Members” of the training site.  I then create the “Attendees” list per her website and set the columns in that the same way she recommends.  Then we get to fire up my trial version of SharePoint Designer 2007.

She says to insert a “DataView” web part into our page.  Ok?  After some hunting I go into the top menu bar and select “Insert – SharePoint Controls – Data View.”  It’s one of several “DataView” webparts that I can find that all seem to function identically.

  Image0002

So the web part is placed on the page.  Now her tutorial and my experience start to differ a little. She says to select the “Classes” list for the data.  Ok.

Image0003

 

Now it asks me which columns I want to display in a panel on the right hand side.  I pick the ones she suggests. Title, Start Time, End Time, Location and Trainer.

Image0004

 

I select “Insert Selected Fields as” and choose “Multiple Item View.”  My results are beginning to look like her example again. In the “Common Data View Tasks” I also select “Show with Sample Data.” This makes it a little easier to see what my results are going to look like.  I have sorted the columns, and inserted a column. (Table, insert Column from the top menu bar.)  I insert the “Form Action Button.” (This is located in the tool box under SharePoint Controls, in the Data View Controls subcategory.)  I select “Custom Action” and click settings, and lo and behold it pops up the workflow editor just like she said it would. (Of course it would, she’s smart and I’m still learning.)  I create a variable, ClassID and set it to “List Item ID.” Now, here comes the part where I am making a mistake, and I cannot for the life of me figure out what I am doing wrong. I create an action to “Create List Item.” (We don’t need conditions because the condition we are defining is the click on the Form Action Button, I think.)  In the Create New List Item dialog box I select the “Attendees” list.  For the title I click on “Modify.” A dialog box pops up for the Value Assignment.  Set This Field is set to “Title,” of course.  Under “To This Value” I hit the formula button (fx). For “Source” in the new window that pops up I select “Classes.” That is the source of the data after all.  For “Field” under “lookup details” I select “Title.”  Seems logical, we want to set the “Title” field of Attendees to match the “Title” field of Classes.  Now I need to tell it which one. So I mosey on down to the bottom portion of “Define Workflow Lookup” and for “Field” I select “Classes:ID.”  Now it should be noted that this was the prescribed selection from here, although I am presented with other options that may also be valid, I’m not sure.  These include “Classes:GUID”, “Classes:Title” (which would likely send me into an infinite loop), “Classes:MasterSeriesItemID”, and “Classes:UID.”  If figure the safe bet is “ClassesID.” For the “Value” field under “Find the List Item,” I hit the formula button again (fx) and in the new window that pops up, I select “Workflow Data” for the source, and “Variable:ClassID” for the field. I go through pretty much the same drill for “Start Time” and “End Time.”  Now, here is where I think I am making my mistake with this workflow.  We have to set that variable that we created somehow.  So I click “Add” in the “Create New List Item” window, and change the field to “ClassID.”  For the Value, I’m off in the formula button again, I select “Workflow Data” for the source and “Classes:ID” for the field.  I check the workflow and it contains no errors. (This just means that it won’t break.  It has an error in it somewhere.)  I click finish and the workflow is compiled.  Then I click “OK” in the Form actions window that was open under everything else this whole time. At this point, I should be able to check my work.  I create a dummy class, and then try to use the form action button to sign up for my dummy class.  It seems to work great.  I check my attendees list, and it has added a class, but it has not passed any of the class information into the list.  I have made a view with the “ClassID” column visible, and a view in the “Classes” list that shows me the “Classes:ID” for my dummy class.  They don’t match.  Somehow my variable that I set is not getting passed.  The logic is there, at least to me, but it isn’t working as advertised.  Now I can use some help from you guys.  What did I set wrong in my workflow?  How do I get this to start working correctly. I want to get this to work right before I move on to the other issues that I am running into.   And please don’t go trying to find a way to harass Natalya, she was nice enough to put up the tutorial.

15 Comments »

  1. I will give it a whirl this week and see what happens. I am working on another deadline, but should have some spare time. I usually insert web parts first, then go to data view, but who knows. I swear SP is messing with my head sometimes. I’ll get back with you at the end of the week to report.

    Comment by starrydynamo — January 21, 2008 @ 3:00 pm

  2. I’m at the same point you are at, or at least it seems so. I have gotten everything to work up until passing information after clicking the sign up button (form action button). i have updated the onClick event, and followed the rest of the tutorial word for word. It seems like the workflow is not capturing all of the necessary information. Let me know if you figure this out.

    Jason

    Comment by jason — January 23, 2008 @ 1:36 pm

  3. Still working on it; will give it another shot.

    Comment by starrydynamo — January 30, 2008 @ 1:07 pm

  4. any luck with this solution?

    Comment by jason — February 5, 2008 @ 8:09 am

  5. I haven’t had any yet. I’m still trying. I think the entire issue is the variable. It seems that it is either not getting set correctly, or not getting passed correctly if it is set. It’s frustrating for sure. If I do get a solution, I will be sure to post it.

    Comment by slinger — February 5, 2008 @ 8:13 am

  6. Guys, there is my blog post for this article http://spforsquirrels.blogspot.com/2008/02/sharepoint-beagle-articles.html
    If you have questions, post it there, I have no problem with answering.
    THe mian problem might be in the javascript string you are using to pass parameters.
    Lot’s of people have the same issue

    Comment by Natalya Voskresenskaya — February 5, 2008 @ 9:39 am

  7. OMG I have the EXACT same problem you have had.

    I did a search on ‘sharepoint “create new list item” in workflow’ to find your site.
    She glosses over some of the steps I am sure are necessary. Too bad because I was hoping to impress the boss with this and I can’t get it working. :<

    Comment by webguy — February 11, 2008 @ 10:24 am

  8. One thing I must say that Natalya is a very nice looking developer :>

    Comment by webguy — February 11, 2008 @ 10:29 am

  9. Well she replied back with:

    Natalya Voskresenskaya said…

    I’ve read the thread that you’ve opened. The error you are making is trying to assign workflow variable ClassID from within the workflow. Workflow is not aware of the ClassID of selected row.
    The value for the selected classes ClassID is being passed to the workflow value from the OnClick event for “Sign Up” button
    javascript: {ddwrt:GenFireServerEvent(concat(‘__workflowStart={{7696F6EA-2079-4A53-A97B-CE61D99A02AB},New,{66402E3B-C94E-4E6F-9936-10E596CC5795},ClassID=’,@ID,’}__redirect={MyClasses.aspx}’))}
    The article if fairly detailed try to follow it step by step. Let me know how it goes.

    Comment by webguy — February 12, 2008 @ 2:28 pm

  10. […] of me I still can’t quite get it to work as advertised.  To get started on it that post is here.Well if you read the comments in my previous post, you will see that the variable that was not […]

    Pingback by Custom Workflow in SharePoint Designer still doesn’t quite work right. « Slinger’s Thoughts — February 13, 2008 @ 10:18 am

  11. ya, I tried what she said and still no go. The parameter is not getting passed to the list. Maybe she’ll update again – here is her link: maybe others can bother about it too :

    https://www.blogger.com/comment.g?blogID=4706575016618798194&postID=6437156822292120296

    Comment by webguy — February 13, 2008 @ 1:18 pm

  12. Just FYI for those of you who did not go to Natalya’s blog… the javascript line must have a semicolon just before __redirect={… After that is set everything works like a charm!

    Comment by Jeremy W — March 14, 2008 @ 2:10 pm

  13. Anyone have this web-part in .dwp format so i can just upload it as a webpart?
    I’ve been unable to get it to work correctly.

    thanks

    Comment by Shawn — April 11, 2008 @ 2:01 pm

  14. Shawn, what problems are you having? MAybe we can help. I don’t know if the Webpart is available as a .dwp

    Comment by slinger — April 11, 2008 @ 2:16 pm

  15. Is it possible to pass through multiple variables to the workflow using this same method? So let’s say that in addition to [ClassID=’,@ID,’] you also wanted to pass through another variable [RegistrationID=’,@RegId,’]. I have attempted this and viewing the generated source code for my page, the @RegId value is being populated, but I either don’t have the syntax correct or the workflow won’t accept more than 1 variable as the page isn’t responding correctly. Any ideas?

    Comment by Jayson G — June 9, 2009 @ 6:48 am


RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.