1,804 articles and 14,827 comments as of Sunday, May 8th, 2011

EndUserSharePoint has combined resources with NothingButSharePoint.com. You can now find End User (Mark Miller), Developer (Jeremy Thake) and IT Pro SharePoint 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 3, 2010

SharePoint: Extending the DVWP – Part 7: Creating a Form Action Workflow

Author: Jim Bob Howard
Last time, we examined what the link looks like for DVWP form action links. This time, let’s see how we can edit them from the Design pane using the Form Actions wizard.

Form Action

Editing the Form Action is another option which, though limited, offers some powerful functions, including workflows.
Form Actions are modified through a wizard which in turn edits the javascript call in the href attribute of our link. Before we launch the wizard, let’s take a quick look at the “before” picture of how our link looks OOTB:

Before

save
  1. Launch the Form Actions wizard (from the Edit Template), by right-clicking on the link and choosing Form Actions…from the menu.
  2. Notice that the Commit action we saw in the Before code appears in the wizard. There are a couple of options in the Actions list that are pretty straightforward:
    1. Refresh simply refreshes the screen, which will reset the edit page with the currently-saved data from the database
    2. Cancel will cancel the edit and take us back to the default view
    3. Navigate to source will take the user to the URL in the source variable in the querystring
    4. Navigate to page is similar to the previous action, but let’s you specify where it goes
  3. To launch/create a workflow, add [Custom action] and click Settings
  4. Custom action (workflow) has been positioned to run before the commit takes place. Click Settings button to

  5. Three things to notice when the Custom action / Workflow Designer wizard launches:
    1. Notice the name of the Workflow
    2. This workflow (on Finish) will be named “Custom Form Action 16″ and will be placed in the Workflow directory for the current site

    3. And notice that there’s no way to make this a “manual,” “on create,” or “on change” workflow. It will be launched only from this link.
    4. No <Back or Next> buttons.

    5. Lastly, notice there is no “Initiation…” button
    6. No Initiation variables can be set, but we can pass in variables (see the next article for details)

  6. Note: If you’re not familiar with workflows, this may not be very clear. I invite you to study the many great articles on EUSP that cover the use of workflows.
  7. Other than those things, create your workflow here just as you would for any other list, with a couple of caveats:
    1. The only condition is to Compare any data source
    2. Compare any data source is the only Condition for a form action workflow

    3. On the Workflow Lookup, there is no Current Item to choose from:
    4. No Current Item from which to choose field comparisons

    5. Form Fields function as Current Item because they’re what’s coming from the form:

Form Fields are those which are on your form, but could also be hidden fields/labels

Next time: The after version of the form action link looks vastly different from what we started with, above. We’ll dig into 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. ExSharePoint: 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

8 Responses to “SharePoint: Extending the DVWP – Part 7: Creating a Form Action Workflow”
  1. Rob says:

    Jim,

    I have been lightly following your entire series but have not got a chance to read them end to end. I was looking forward to this article to solve a problem I have and the article did exactly that but I believe I need your insight. I hope you can suggest something or point me in the right direction. I will try and be precise in my explanation. I could also be wrong of using a Workflow to solve my problem? (share your thoughts) So here it goes…

    I have a SharePoint Survey created for my users for which I have a custom NewForm.aspx. There are a total of 8 questions. Q6 is ‘Comments’ (multi-line) and Q7 is ‘Did you like the site’ (Choice of Yes/No) is the question with a branching logic: if on Q7 the user selects ‘No’ then allow him/her to fill additional comments and ONLY after he/she fills out Q8 (Q8 ‘Add Comments Please, why you did not like the site) allow the submit (commit) to happen, otherwise (if ‘Yes’) then move on to Q6 and let the user submit the Survey. Since my NewForm.aspx is custom I was planning to write a Workflow for my task via the [custiom action] under Form Actions on my ‘Submit Survey Button’.

    When all is said and done my Submit Survey button would have the below Form Actions in the order I mention.

    [Cutom Action] (where the user is directed if he/she choose Q7 as ‘No’) (need help on this one)
    Commit (save the Survey data) (works)
    Navigate to Page (a thank you page) (works)

    Thanks,
    Rob.

    • Dear Rob,

      Take a look a the URL when you get to Q8. If the only branching you have is at Q7, you’ll be on NewForm for Q1-7. Once/If it branches for Q8, you’ll find you’re now on EditForm. So, if you’re working with a Custom Action workflow, you’ll have to make sure it’s on EditForm, rather than NewForm.

      If you’re still running into trouble, post more details in Stump the Panel and post a link in the comments here.

      Blessings,
      Jim Bob

  2. Joe says:

    Hi Jim Bob – its me again. I cant find much on the web about Form Actions Workflows, so i thought id ask you again. I have a Form Actions Workflow that simply has one step – I have a button on each list item of a dataview that, when pressed, passes in to the form actions workflow the current user’s name with a variable called myVar and the ID of the current list item. Then the form actions workflow does a lookup on the list with the ID i passed in and sets a field in that item to myVar (the current user’s name).

    This seems to work great about 95% of the time – but it doest appear to work at all the other 5%… I mean, i dont think the Form Actions Workflow even runs when i click the button sometimes. I can replicate the problem with some success if i havent tried to run the workflow in a while or if i let the page site idle for a few minues before clicking the button which triggers the workflow.
    If i can get the workflow to run though, it seems that it will keep working if i use it very frequently.

    Does that make any sense (both my explanation and the error (or lack there-of))?
    Thanks,
    Joe

    • Joe,

      I’m heading out for the day scratching my head about that one… but I’ll revisit it tomorrow and see what I can figure out.

      Thanks for your patience.

      Blessings,
      Jim Bob

      • I must admit that you’re running into an odd error.

        But, if all you’re doing is updating a list, I wouldn’t use a workflow for it; I would use jQuery and SPServices to update the list without calling a workflow. You can do the exact thing you’re wanting to do with that scenario. The only difference, of course, is that you won’t have a workflow history built in. So you might have to create an audit list to record the changes you make when the button it clicked.

        If you’d like to walk out that scenario, let’s take it over to STP where we can look at the code a little easier.

        Blessings,
        Jim Bob

Trackbacks

Check out what others are saying about this post...
  1. [...] 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. [...]

  2. [...] 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 [...]

  3. [...] we have them looking the way we want 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!