1,804 articles and 14,815 comments as of Monday, May 9th, 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, July 29, 2010

SharePoint: Extending the DVWP – Part 23: Creating Title Based on Other Fields with a Workflow

Author: Jim Bob Howard

When working with cascading dropdowns and the Relationship lists that accompany them, the important part of the Relationship list is that the site columns we’re relating are set. The Title of the list time doesn’t matter to the cascading process.

However, from a human maintenance standpoint, that Title can make things a whole lot easier. Last time, we automated its creation using jQuery. I know not everyone enjoys jQuery as much as I do. But, I have good news for you…

You can do almost the same thing with a workflow.

Creating a Title Within a Workflow

Of course, you’ll need SharePoint Designer to create the workflow. So, launch that and open your site:


Site opened in SharePoint Designer

  1. Click the arrow next to the new document icon and choose Workflow:

  2. Site opened in SharePoint Designer

    You may see this message:


    …if so, just wait and then you’ll see the Workflow wizard


  3. Give it a name

  4. Choose the list

  5. Uncheck "manual start" and check "on create start"

  6. Click Next

  7. Then click Actions and choose Build Dynamic String

  8. Click on dynamic string

  9. Click Add Lookup

  10. Leave Source as Current Item, and set Field to the first field you want to be part of the Title. In mine, I want Date of Incident:

  11. Click OK
  12. Type a space, a dash, and another space (or whatever naming convention you want):


  13. Click Add Lookup again
  14. This time, choose the second field you want to use (I’ll use Type of Incident):


  15. Click OK twice
  16. Click on Variable: variable 1

  17. Then click on Create a new variable…


  18. Name it

  19. Click Actions and choose Update List Item

  20. Click this list

  21. Click Add and choose Title under Set this field

  22. Click the fx button
  23. Change the Source to Workflow Data and Field to txtTitle


  24. Click OK three times
  25. Click Finish

Now you have a "dynamic" Title.

Caveats

The downsides to using a workflow are irritating, but not necessarily show-stoppers.

  1. The most obvious downside is that the Title is not set immediately. The workflow takes a little time to process. In the meantime, it will be blank and could confuse users, mess up sorting on that field, and generally look less than optimal.
  2. Any field used in the Title must either be required or you must check for it in the workflow and give a default if not found. If you’ve worked with workflows for any time, you’ll know that using conditionals and branching is non-trivial.
  3. If the workflow ends with an error, your Title may never be set.
  4. If the fields used to set the Title change, it’ll be out of sync. To get it back in sync, you’ll have to write a WF that runs on create AND change, but you’ll have to keep track of the fields and check to see IF they changed before changing the Title.
  5. If you’re keeping track of versions, you’ll have a new version every time the Title gets set or reset.
  6. Showstopper: If the creator doesn’t have Edit permissions (e.g. Contribute w/o Edit), this WF will fail because the workflow runs under their ID so Update List Item will be denied access.

Next time: We’ll look at creating list items with SPServices next.

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

6 Responses to “SharePoint: Extending the DVWP – Part 23: Creating Title Based on Other Fields with a Workflow”
  1. Greg says:

    Jim,
    What drawbacks to you see to the jQuery option?
    Seems that if you are confortable with jQuery and already using it on the same page, the workflow option is less reliable.
    Correct?
    Greg

    • Dear Greg,

      Correct. I prefer not to use the workflow option for this, but I present it as a contrast for how great the jQuery option is. ;) I think jQuery FAR excels the workflow in this case.

      But, if you aren’t already using jQuery, but ARE already using a workflow (and the other caveats don’t apply or can be mitigated), then you might as well throw the Title-naming into the workflow.

      Blessings,
      Jim Bob

  2. Emmana says:

    Hello Jim,

    I need your assistance, I have created a workflow in share point designer as shown above but then, it does not send emails. Other things work, it populates the group it is not sending email.
    I get errors like this:
    10/8/2010 11:43 PM Error System Account
    The e-mail message cannot be sent. Make sure the outgoing e-mail settings for the server are configured correctly.

    Can you help to tell me what to do? Are there still settings I need to set before the workflow will work.

    Other workflows in their own documet library works

    Emmana

  3. Terry says:

    Hello Jim,

    I have used your example to create a title from other fields using Workflow and it works great. However one of the fields I am using is a People or Group type. When I select that field as part of my title, what is created is “Domain\JSmith”. What I really what it to say is John Smith. Is there a way I can get the full name?

    Terry

    • Dear Terry,

      Yes, but it’s a little tricky. Three options of the top of my head:

      1. Install the SPDActivities.codeplex.com project, which will give you a Lookup User Info action in the workflow. Using that, you can look up “Display Name” which is what you’re looking for; and you can put that in the Title field.

      2. By Nintex Workflow, which allows calls to SharePoint Web Services and will allow you to do the same thing. (This is about the fourth time this week I’ve recommended Nintex, but I’m not associated with them in any way. As I’ve stated elsewhere, I haven’t even used it; but colleagues I admire greatly speak very highly of it. The pricetag is up there, but the increased WF functionality appears to be exemplary!)

      3. Instead of a workflow, use the technique in Part 22 of this series to look up the user name with jQuery and SPServices and store it in the Title field when the item is saved the first time.

      Hope that helps!

      Blessings,
      Jim Bob

Trackbacks

Check out what others are saying about this post...
  1. [...] columns. We can let SharePoint fill that data in for us with jQuery. Alternately, we could fire up a workflow to do it [...]




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!