1,804 articles and 14,766 comments as of Tuesday, April 19th, 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, August 19, 2010

SharePoint: Extending the DVWP – Part 29: Modifying Form Action Workflows on the remove Template

Author: Jim Bob Howard

Marty McFly: "Heavy!"

Doc Brown: "There’s that word again! Is there something wrong with the Earth’s gravitational pull in the future?"

If the last few articles have been a bit heavy, hopefully today’s will be a little lighter, because we’ve already done some of this in Parts 7 thru 12, when we first created form action workflows.

But don’t skip this one.

There are some potential pitfalls we want to avoid with the work we’ll be doing today. I’ll draw special attention as we come to them so you’ll definitely know when you’re getting close.

Shall we?

Meanwhile, Back at the Ranch…

When we last saw our hero, the mild-mannered edit template had almost completed the transformation to the superhero known as remove template.


But not quite…

The Terminated and Resigned buttons are form action links but, right now, they’re still acting like the Save link on the edit template. So, let’s finish the transformation of our superhero.

  1. In SharePoint Designer (SPD), right-click on Terminated and choose Form Actions
  2. Pitfall Alert!!!

  3. If you have already created a [Custom Action] for your edit template, it will show up here, too. Do NOT click the Settings… button! If you do, you will be editing the workflow that really should only be associated with the Save button on the edit template.
  4. Instead, click the [Custom Action], then << Remove, and then OK. This will remove all connection to the Save workflow.


    Remove the existing [Custom action] to disconnect this form action link from it.

  5. Right-click on Terminated and choose Form Actions again.
  6. Click [Custom Action], then Add >> to start creating a new workflow for this link.
  7. Click Move Up to make sure the workflow runs first.

  8. Now that you’re starting with a clean slate, you can begin setting up the workflow this form action will call

  9. THEN, you can click the Settings… button to configure the workflow.

Workflow, She Wrote

We’ve been through writing to the Audit list using SPServices in the PreSaveAction() and we’ve talked about how we can get our form data and other variables into the workflow.

Since we made labels out of our controls (except Effective Date), we’ll have access to all of them in the workflow. So let’s use the Create List Item action:

  1. Choose your audit list and all of the required fields will be displayed for you. Simply walk through each one, clicking Modify… for each and choosing your form fields for the value:

  2. Required fields will automatically be added to the Create New List Item dialog

  3. When you get to Change Type, choose Terminate from the choice field list

  4. When you’re all done, click OK, Finish, and OK. (If you come back to edit this later, see Pitfall Alert! below before clicking second OK.)
  5. Make note of the workflow number in the pop-up that displays next. (You might want to add a comment to your XSLT to make it easy to remember which you’re working with later.)

  6. Rinse and repeat for the Resign button.

Pitfall Alert!!!

If you build on this example using the techniques we discussed in Part 10: Passing Workflow Variables to a Form Action Workflow, DON’T click the second OK. Doing so will overwrite the changes you made to pass in workflow variables.

Just remember that the form action and the workflow are two separate entities. To have access to your form fields and workflow variables in the workflow, you have to go thru the form action as shown. BUT, if you don’t want your variables overwritten, don’t click OK on the Form Actions once you’ve done your initial creation of the workflow.

When you’re done using the Design pane to step through the remove template, be sure to switch the template names back

<xsl:template name="dvt_1.rowremove">
    <xsl:param name="Pos" />
    <tr>
        . . .
    </tr>
</xsl:template>
<xsl:template name="dvt_1.rowedit">
    <xsl:param name="Pos" />
    <tr>
        . . .
    </tr>
</xsl:template>

…goes back to…

<xsl:template name="dvt_1.rowedit">
    <xsl:param name="Pos" />
    <tr>
        . . .
    </tr>
</xsl:template>
<xsl:template name="dvt_1.rowremove">
    <xsl:param name="Pos" />
    <tr>
        . . .
    </tr>
</xsl:template>

Next time, we’ll keep Extending the DVWP by adding some filters and Easy Tabs to make it easier to keep things separate, while grouping them into easier-to-maintain collections.

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

3 Responses to “SharePoint: Extending the DVWP – Part 29: Modifying Form Action Workflows on the remove Template”
  1. Richard says:

    Hi Jim,

    I am getting an error whenever I try to initiate a form action workflow for both save and delete form actions. I thought it might be a missing $POS variable in dvt_1.automode template, but SPD 2010 adds that variable for me. The error is inside the browser, not SPD. Thanks!

    Richard


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!