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

Form Action
Before
save
- Launch the Form Actions wizard (from the Edit Template), by right-clicking on the link and choosing Form Actions…from the menu.
- 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:
- Refresh simply refreshes the screen, which will reset the edit page with the currently-saved data from the database
- Cancel will cancel the edit and take us back to the default view
- Navigate to source will take the user to the URL in the source variable in the querystring
- Navigate to page is similar to the previous action, but let’s you specify where it goes
- To launch/create a workflow, add [Custom action] and click Settings
- Three things to notice when the Custom action / Workflow Designer wizard launches:
- Notice the name of the Workflow
- 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.
- Lastly, notice there is no “Initiation…” button
This workflow (on Finish) will be named “Custom Form Action 16″ and will be placed in the Workflow directory for the current site
No <Back or Next> buttons.
No Initiation variables can be set, but we can pass in variables (see the next article for details)
- Other than those things, create your workflow here just as you would for any other list, with a couple of caveats:
- The only condition is to Compare any data source
- On the Workflow Lookup, there is no Current Item to choose from:
- Form Fields function as Current Item because they’re what’s coming from the form:
Compare any data source is the only Condition for a form action workflow
No Current Item from which to choose field comparisons


Custom action (workflow) has been positioned to run before the commit takes place. Click Settings button to

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

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