1,804 articles and 14,395 comments as of Monday, January 3rd, 2011

EndUserSharePoint has combined resources with NothingButSharePoint.com. You can now find End User (Mark Miller), Developer (Jeremy Thake) and IT Pro SharePoint (Joel Oleson) content all in one place!

This site is a historical archive and is no longer being updated. Please update your favorites, bookmarks and RSS feeds.

NothingButSharePoint.com
Tuesday, June 8, 2010

SharePoint: Extending the DVWP – Part 8: Creating a Form Action Workflow – The After Math

Author: Jim Bob Howard

In the previous article, we looked at the Before view of a Form action link. This time, let’s see what happens after we create the workflow.

Picking up where we left off, create a simple workflow that uses all of the form fields. (It doesn’t matter what action you do, as long as all of the form fields are used. We’re going to change the workflow actions anyway.)

Now that we’ve created a workflow, let’s see how that changes the JavaScript call in our link HREF.

After

<a href="javascript: {ddwrt:GenFireServerEvent(concat('__workflowStart={{A50B3A56-0C82-43E3-917E-D37E2E036F3B},New,{F6244C84-AAE5-45E0-9C71-60F6AB31F584},ff1_x007b__x0024_Pos_x007d_={ff1',$Pos,'}*ff2_x007b__x0024_Pos_x007d_={ff2',$Pos,'}*ff3_x007b__x0024_Pos_x007d_={ff3',$Pos,'}*ff4_x007b__x0024_Pos_x007d_={ff4',$Pos,'}*ff5_x007b__x0024_Pos_x007d_={ff5',$Pos,'}*ff6_x007b__x0024_Pos_x007d_={ff6',$Pos,'}*ff7_x007b__x0024_Pos_x007d_={ff7',$Pos,'}*};__commit'))}">save</a>

WOW! That’s quite a bit of code that was added. But, let’s break it down a bit to see what’s going on.

There’s really only one additional piece added to this puzzle, the concat() function, and its purpose is only to pass some variables to the new trigger for the custom action (__workflowStart) along with the commit function:

  1.  ddwrt:GenFireServerEvent() – This is the same code that was already there. Before it was receiving a string. It’s still receiving a string, it’s just a bit longer.
  2. concat() – Takes a bunch of comma-separated strings and/or variables; and then outputs one long string with all of them included. Inside this function, we can see that both of our actions are part of the concatenation, and are in the order we put them when the workflow was created:
    1. __workflowStart – The workflowStart function is being passed 4 parameters:
      1. The GUID of the Workflow
      2. A string: ‘New’ (anyone know what options are valid here?)
      3. Another GUID (anyone know what it points to?)
      4. An asterisk-delimited list of key/value pairs, representing the form fields and the data they contain – And, thankfully, that’s the only part we care about. This is one long parameter with the syntax: fieldname1=value1*fieldname2=value2*…fieldnameN=valueN*
    2. __commit – As we’ve seen, this is simply the function that commits our changes to the database

So the fourth parameter looks like this:

ff1_x007b__x0024_Pos_x007d_={ff1',$Pos,'}*ff2_x007b__x0024_Pos_x007d_={ff2',$Pos,'}*ff3_x007b__x0024_Pos_x007d_={ff3',$Pos,'}*ff4_x007b__x0024_Pos_x007d_={ff4',$Pos,'}*ff5_x007b__x0024_Pos_x007d_={ff5',$Pos,'}*ff6_x007b__x0024_Pos_x007d_={ff6',$Pos,'}*ff7_x007b__x0024_Pos_x007d_={ff7',$Pos,'}*

Or, more readable:

ff1_x007b__x0024_Pos_x007d_={ff1',$Pos,'}*
ff2_x007b__x0024_Pos_x007d_={ff2',$Pos,'}*
ff3_x007b__x0024_Pos_x007d_={ff3',$Pos,'}*
. . .
ff7_x007b__x0024_Pos_x007d_={ff7',$Pos,'}*

Each key/value pair ends up looking like:

Long SharePoint-generated field name that starts with an ff and a number (n) which represents its order on the page={ffn_1}

The "_1" portion comes from the param $Pos which turns it into a "_1" on the client side. Then when it’s passed to the workflow, the actual value of the form field ffn_1 is inserted because it’s inside {}, which causes it to be exchanged with the actual value for that field on the page.

In other words: If ff1 represents the Name column and the form field has "John" in it… by the time the key/value pair makes it to the workflow, it looks like: ff1_x007b__x0024_Pos_x007d_=John. (Don’t worry about  the x00XX notation. It gets converted, too, for workflow purposes. From a human readability standpoint, it would come out to ff1{_$Pos} but that doesn’t really help it be more readable.)

Failed setting processor stylesheet ???

Did you get this error?

Next Time in Extending the DVWP, we’ll talk about why you got it and… more importantly… how to fix it.

Author: Jim Bob Howard

Jim Bob Howard is a web designer / webmaster in the healthcare industry. He has been working with SharePoint since March 2009 and enjoys sharing what he has learned. He is a moderator and frequent contributor to Stump the Panel, and answers SharePoint questions on Twitter (@jbhoward) and via email ([email protected]).

View all entries in this series: Extending the DVWP»
Entries in this series:
  1. SharePoint: Extending the DVWP - Part 1: Layout Enhancement - Rearranging Columns - Default and Edit Templates
  2. SharePoint: Extending the DVWP - Part 2: Layout Enhancement - Rearranging Columns - Insert Template
  3. SharePoint: Extending the DVWP – Part 3: Getting it All on One Line - DVWP Function Action Links
  4. SharePoint: Extending the DVWP – Part 4: Turning DVWP Action Links into Buttons
  5. SharePoint: Extending the DVWP – Part 5: Doing Stuff Before Save on Submit - PreSaveAction()
  6. SharePoint: Extending the DVWP – Part 6: Examining the Form Action Links
  7. SharePoint: Extending the DVWP – Part 7: Creating a Form Action Workflow
  8. SharePoint: Extending the DVWP – Part 8: Creating a Form Action Workflow - The After Math
  9. SharePoint: Extending the DVWP – Part 9: Oops! Failed Setting Processor Stylesheet
  10. SharePoint: Extending the DVWP – Part 10: Passing Workflow Variables to a Form Action Workflow
  11. SharePoint: Extending the DVWP – Part 11: Getting More Form Fields to the Workflow
  12. SharePoint: Extending the DVWP – Part 12: Adding More Form Fields from the Data
  13. SharePoint: Extending the DVWP – Part 13: Putting PreSaveAction() to Work – Creating Variables
  14. SharePoint: Extending the DVWP – Part 14: Putting PreSaveAction() to Work with jQuery
  15. SharePoint: Extending the DVWP – Part 15: User-Managed Dropdowns with Site Columns
  16. SharePoint: Extending the DVWP – Part 16: User-Managed Dropdowns - Loading Data
  17. SharePoint: Extending the DVWP – Part 17: User-Managed Dropdowns – Creating a Relationship list
  18. SharePoint: Extending the DVWP – Part 18: User-Managed Dropdowns – Loading the Relationship list – Part 1
  19. SharePoint: Extending the DVWP – Part 19: User-Managed Dropdowns – Loading the Relationship list – Part 2
  20. SharePoint: Extending the DVWP – Part 20: Cascading Dropdowns - Applying the jQuery
  21. SharePoint: Extending the DVWP – Part 21: Cascading Dropdowns - Three-tier Cascade
  22. SharePoint: Extending the DVWP – Part 22: Creating Title Based on Other Fields with jQuery
  23. SharePoint: Extending the DVWP – Part 23: Creating Title Based on Other Fields with a Workflow
  24. SharePoint: Extending the DVWP – Part 24: A Note to Readers
  25. SharePoint: Extending the DVWP – Part 25: Using an Audit Trail by Creating List Items with SPServices
  26. SharePoint: Extending the DVWP – Part 26: Modifying the Edit Template
  27. SharePoint: Extending the DVWP – Part 27: Adding an Alternate Edit Template to a DVWP
  28. SharePoint: Extending the DVWP – Part 28: Massage the Remove Template
  29. SharePoint: Extending the DVWP – Part 29: Modifying Form Action Workflows on the remove Template
  30. SharePoint: Extending the DVWP – Part 30: Using EasyTabs with Filtered DVWPs to Make Data Manageable
  31. SharePoint: Extending the DVWP – Part 31: Filling in Default Data on the insert Template with jQuery
  32. SharePoint: Extending the DVWP – Part 32: Filling in Default Data on the insert Template with Multiple DVWPs
  33. SharePoint: Extending the DVWP – Part 33: Modifying Total and Subtotal Row Layouts in DVWP
  34. SharePoint: Extending the DVWP – Part 34: Using Icons for Form Action Links
  35. SharePoint: Extending the DVWP – Part 35: Putting it All Together
  36. SharePoint: Extending the DVWP – Bonus: Fixing the Insert Form Action When "No Matching Items"
  37. SharePoint: Extending the DVWP – Bonus: Creating a Title Based on Dropdowns with jQuery
 

Please Join the Discussion

19 Responses to “SharePoint: Extending the DVWP – Part 8: Creating a Form Action Workflow – The After Math”
  1. Any feedback on this series of articles? Is this stuff valuable? Any “Holy Smokes” out there? Any questions, comments, outbursts? :)

    Blessings,
    Jim Bob

  2. Colin Rippey says:

    Hi Jim,

    I’ve been following along with these articles with great interest. My only feedback would have been to have made each article longer so that instead of 8 (so far) you would have had 4.

    It’s good to see you call out some of the esoteric bits of the javascript calls that get created by designer as stuff like this can lead to people to realise that’s there maybe jquery ways to get server side actions running from custom front-end pages (of course if the javascript is supposed to be undocument then “here be dragons” is your motto).

    Cheers,

    Colin

    • Thanks, Colin.

      We debated how long (and therefore how many) the articles should be for this series. The general consensus was that the content is “deep water,” as George says. And therefore it would be better to descend slowly to avoid drowning. Also, the smaller chunks are meant (in most cases) to be somewhat self-contained, so that the concepts can be encapsulated and reusable in various projects.

      Were we to combine all of these into an eBook, there are several that could be joined together in one chapter. And several others could be their own chapters.

      In most cases, we’ve erred toward shorter blog posts with a view to present complete concepts.

      I really appreciate the feedback. And if “Here be Dragons,” I hope to remove some of the mysticism and adopt a new motto: “Here be (Slain) Dragons.” :)

      Blessings,
      Jim Bob

  3. George W says:

    Jim Bob:
    This set of articles is a great help on a topic that has little or no understandable documentation. Thank you for all the hard work.

    However, you’ve not provided any context for heading into these deep waters. Part 1 started off manipulating an Announcements List, then you had several articles with no reference to fields at all, now you’re firing off a mysterious Workflow whose steps we never see with @LocDept, @Group12, @Positions, and @FTE (!).

    I’d like to know more about the specific business reason why you are using this method to kick off a workflow, instead of relying on other ways (new item, changed item).

    And why I should put FTE in my alphabet soup!

    Cordially,

    George

    • Dear George,

      Thanks so much for the honest and gracious feedback!

      While I am definitely going somewhere with all of this (and it’s called “FTE” ;) ), much of what I’m presenting doesn’t have to be a single step in a large project. My goal is to share these concepts so that the reader can plug-and-play into his specific project.

      All that said, the series will culminate in with: “How I Created a SharePoint List to Replace an Excel Spreadsheet—Which Recorded Changes to Full-Time Employee (FTE) Headcount, and Was Being Routed to 15+ Managers Every Month—by Creating a Web Part Page for Each Manager Which Displays an Editable Table of Employee Information Filtered into Easy-to-Read/Update Tabs, Using Site Columns, Cascading Dropdowns, DVWPs, EasyTabs, Form Action & List Workflows, PreSaveAction(), SPServices/jQuery, XSLT, and CSS; and Extends the DVWP Edit Template to Treat Delete as Edit for the Purposes of Writing an Audit Trail for Everything That Happens.” :)

      Perhaps it’s time to do a screencast of the finished product.

      Does that help? A little?

      Blessings,
      Jim Bob

  4. Bill C says:

    Thanks for the information. You must have a real light work-load at your job to be posting this much detail and responding so quickly…”Holy Smokes”

    • LOL. Not really, Bill.

      I just know that if I don’t answer quickly, I’ll forget what I did and won’t be able to answer at all. ;) The detail is a result of this coming from my own documentation for this particular project. I’m one of only two SP developers (and the other one is stepping out of the role), so I have to document in a very detailed manner so I’ll remember what I did. ;)

      And you’re very welcome for the information. I’m glad it’s a help.

      Blessings,
      Jim Bob

      P.S. What you’re reading was compiled over a few months and broken down into bite-size chunks (about 22 so far, with more to go), so I’m not working exclusively on this series while it’s being published. ;)

  5. Brian Bedard says:

    According to Reflector:

    public string GenFireWorkflowStart(string listName, string itemID, string workflowId, string workflowParams)
    {
    return base.GenFireServerEvent(”__workflowStart={” + listName + “,” + itemID + “,” + workflowId + “,” + workflowParams + “};__redirectSource;__redirectToList={listName};”);
    }

    maybe the first param can be the listurl like we use when defining lookups
    the second parameter is the itemId, so New and a number are valid values
    the third parameter is the workflow instance id
    and the fourth, well now I understand why its an * delimited list (not so odd now) [comma was taken]

  6. Mia Yu says:

    Hi ,

    Thanks for sharing, i’m trying to use Form Action Workflow for multiple items update. But i wonder if it cause system resource problem like connection full or anything else when i run the form action workflow in javascript within a loop ???

    • Dear Mia,

      I don’t see a problem with updating multiple items in a loop. Workflows do have a bit of timing overhead, but I’ve done it lots of times.

      For large numbers of updates, I’ve used SPServices (both synchronously and asynchronously) and haven’t noticed any performance issues.

      I recently ran through almost 1000 active directory records via a web service; retrieved organization upline information for each user through recursive calls to that web service, then retrieved organizational downline information for each manager through recursive calls; pulled user profile information from SharePoint (also via a web service), compared each item with existing records in another SP list and wrote out the ones that were missing or needed to be updated. All told, there were probably 5 or 6 thousand web service calls, with just under 700 writes to SharePoint. It took about 10 minutes to run, but no errors, hangs, or corruptions.

      Hope that helps.

      Blessings,
      Jim Bob

      • Mia Yu says:

        Hi Jill,

        Thanks, This response give me confidence about Form Action Workflow solution. I also want to use web service to manipulate list, but i can only use javascript because IT restrict us to run server code like apsx code. Unfortunately my data is more than 20,000, so i still looking some batch or bulk solution. could you give me some suggestion ? I’m thinking using excel file or xml and directly insert itemlist to list folder in webservice. Do you think is this workable?

        Regards,
        Mia

      • Dear Mia,

        Of course, you could copy/paste a range of Excel cells into a datasheet view.

        Hope that helps.

        Blessings,
        Jim Bob

Trackbacks

Check out what others are saying about this post...
  1. [...] Dataview Web Part (DVWP) form action links using Form Fields (or if you were following along on the last article), you probably saw this error when you went back to the Design [...]

  2. [...] covered this syntax in more depth two articles ago. This time, we’re only going to look at the fourth parameter in the __workflowStart [...]

  3. [...] them, we’ll open them up, see how they work, add a PreSaveAction(), add a  workflow, rearrange some things, and then fix what we [...]




Notify me of comments to this article:


Speak and you will be heard.

We check comments hourly.
If you want a pic to show with your comment, go get a gravatar!