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
Thursday, June 10, 2010

SharePoint: Extending the DVWP – Part 9: Oops! Failed Setting Processor Stylesheet

Author: Jim Bob Howard

If you’ve tried to add workflow to 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 pane:

Failed setting processor stylesheet


Notice it says, A reference to variable or parameter ‘Pos’ cannot be resolved. The variable or parameter may not be defined, or it may not be in scope. It’s true, this parameter is not in scope out-of-the-box, because it’s not passed into this specific template which is used to draw the save and cancel buttons.

1. In the Code pane, search for :template name="dvt_1.automode":

<xsl:template name="dvt_1.automode">
        <xsl:param name="KeyField" />
        <xsl:param name="KeyValue" />
        <xsl:param name="Mode" />
       . . .

2. So, let’s get it in scope. The first thing will be to add it to the list of xsl:param calls on this template:

<xsl:template name="dvt_1.automode">
        <xsl:param name="KeyField" />
        <xsl:param name="KeyValue" />
        <xsl:param name="Mode" />
        <xsl:param name="Pos" />
       . . .

Easy enough. But…

3. If calls to this template don’t include xsl:with-param for Pos, we’re still going to have trouble. That means every call to this template must pass Pos along, if you add a workflow that accesses the form fields.

When I search my webpart, there are three calls to <xsl:call-template name="dvt_1.automode">, one for each of the display templates: default, edit, and insert;so each of those will need to have something passed along through Pos. For the most part, we simply want to pass along the variable already defined by the template calling this one:  <xsl:with-param name="Pos" select="$Pos"/>, which basically takes the current value of Pos that is in scope and passes it down into this one.

<xsl:call-template name="dvt_1.automode">
        <xsl:with-param name="KeyField">ID</xsl:with-param>
        <xsl:with-param name="KeyValue" select="ddwrt:EscapeDelims(string(@ID))" />
        <xsl:with-param name="Mode">edit</xsl:with-param>
        <xsl:with-param name="Pos" select="$Pos"/> // simply insert this line to pass the $Pos value down
</xsl:call-template>

4. One more issue: The dvt_1.rowview template calls the dvt_1.automode, but doesn’t have $Pos in scope. So, we’ll need to pass it into that template so it can pass it on to the next one.

    1. Search for :template name="dvt_1.body"
    2. <xsl:template name="dvt_1.body">
              <xsl:param name="Rows"/>
              <xsl:for-each select="$Rows">
                      <xsl:choose>
                              <xsl:when test="$dvt_1_form_editkey = ddwrt:EscapeDelims(string(@ID))">
                                      <xsl:call-template name="dvt_1.rowedit">
                                              <xsl:with-param name="Pos" select="concat('_', position())" />
                                      </xsl:call-template>
                              </xsl:when>
                              <xsl:otherwise>
                                      <xsl:call-template name="dvt_1.rowview" />
                              </xsl:otherwise>
                      </xsl:choose>
              </xsl:for-each>
      </xsl:template>
      

      This block is the entire template for the body of the form. It will either draw the edit view, or it will draw standard row view. Look at line 2032 above.

    3. This is known as an empty tag, meaning it opens and closes all in one tag. To "open" the tag, we’ll need to remove the / from the end of line 2032 and add the closing tag </xsl:call-template> after the tag. Then we can add the with-param tag, like in the template call to dvt_1.rowedit:
    4. <xsl:otherwise>
              <xsl:call-template name="dvt_1.rowview">
                      <xsl:with-param name="Pos" select="concat('_', position())" />
              </xsl:call-template>
      </xsl:otherwise>
      
    5. Just below this code, you will most likely find the template definition for dvt_1.rowview (if not, search for :template name="dvt_1.rowview"). We now need to add the $Pos parameter to this template so it can receive the with-param value we just added to the call-template.
<xsl:template name="dvt_1.rowview">
        <xsl:param name="Pos"/>
        . . .

You can now call a workflow from your DVWP and access the content the user just entered or edited.

Yes, this is squarely advanced XSLT editing. Need help? See Marc Anderson’s excellent EUSP series Unlocking the Mysteries of Data View Web Part XSL Tags.

Next time: Wouldn’t it be great if you could pass a variable to your workflow, too? You can. I’ll cover that in the next installment of Extending the DVWP.

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

4 Responses to “SharePoint: Extending the DVWP – Part 9: Oops! Failed Setting Processor Stylesheet”
  1. Greg says:

    Jim,
    Indeed advanced XSL but as you mentioned, Marc’s series and eBook is going to help with calling templates ‘with’ parameters and making sure on the other side, the template is ready to receive the parameter (using ).

    Since the Pos parameter is defined as

    I think you may have a typo at the end of your precedent article when it reads:
    From a human readability standpoint, it would come out to ff1{_$Pos} but that doesn’t really help it be more readable.)

    It should read ‘come out to ff1{$Pos}’ right? ;-)

    Quite clever to figure out how to resolve the error thrown by SPD. Makes a lot of sense after the facts but nice debugging!

    Greg

  2. Richard says:

    Hello Jim,

    I had an issue with SPD 2010 and form action workflows that is now resolved. SPD 2010 adds a $Pos variable and value to the dvt_1.automode template when you try to create a form action workflow. It doesn’t help. It needs to be deleted, and the instructions that you provided here need to be followed instead. The workflow will then work! Thanks.

  3. Nice! Glad this helped.

    Blessings,
    Jim Bob


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!