Workflows running twice


I’ve found that in some cases during a migration, workflows may have the ability to run twice. You can even start a brand new workflow for a list, and even that will run twice. I looked more into it, and it appears that upon migration, both the 14 and 15 version event receivers were present. I did some powershell to find and remove the 14 (I’m on SP2013) event receivers.

$spWeb = Get-SPWeb -Identity http://sitewebappURL

$spList = $spWeb.Lists["List Name Here"]

$spList.EventReceivers | Format-List Id, Assembly, Type, Class

#Find the event receivers of ItemAdded and ItemUpdated for the old version (14 if you are on sp2013, 12 if you are on sp2010, so on). Make sure this output spits out the correct receiver you are trying to delete!

$spList.EventReceivers[#]

#Use the following command to delete the old version of the event receiver. Be careful not to delete the wrong one!

$spList.EventReceivers[#].Delete()

$spList.Update()

Then, try the workflow out again, and it should only run once.

Passing Current User to another web application (ASPX)


Man, it’s been awhile since I lasted did a post. There have been a lot of changes. I have a new job and am doing consultant work now. I’m diving much more into SharePoint 2013. In fact, I am taking the 70-331 exam this month, so that should be a good step up for my bag of certifications. Anywho..

I had a requirement where I needed to grab the current user and pass the username off to another web application. How I got it to work was to embed the web application in a SharePoint app which just consisted of a web application page. All you need to do is:

1. Start up Visual Studios -> New -> Project -> SharePoint Empty Project (2013)
2. Then right click the Project -> Add -> New Item -> Application Page.
3. From here, make your application page the same page that you want to embed, carrying over any supporting files.
4. Make sure from here the application page runs correctly (taking note that there is no credential passing yet)
5. Add a reference to Microsoft.SharePoint to your project.
6. Then, let’s assume your app page is called Default. You want to edit your .aspx.cs file

Add:

using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

Also add on Default.aspx.cs:

SPWeb theSite = SPControl.GetContextWeb(Context);
SPUser theUser = theSite.CurrentUser;
string strUserName = theUser.LoginName;

Now you have control over the SPContext, so you can use that to pass objects off to the web application you need it to be.

SharePoint Designer Workflow – E-mail Body String


So I was working on a SharePoint Designer workflow and it seems as though the e-mail body was not rendering or reading the text that was in the body, it was including all of the markup with it. I was trying to include the body of an email to log to the history list.

lookupbodyworkflow

When the workflow ran, the email body output looked like this:

Image

The problem here is that the Body column is allowing Rich Format. All you have to do is change the Body format back to Plain Text.
Image

Then try to use your workflow again using E-mail Body (as string). It should show up correctly now.

Moving SharePoint Designer Workflows


So I decided to make the move and promote my site to a site collection because they were getting a little big and put that site collection on it’s own content database. I used purchased 3rd party tools, so don’t ask me how I did that. ;) Anyway, I had these nicely developed Sharepoint Designer workflows that I have in the mix and I definitely don’t want to recreate them and I don’t want to lose them. How about moving them? Can I do that? I did some research and I’ll post how I did that successfully here.

(It’s been awhile huh?)

First, go to the site you have the workflows on. The source site if you will. From here, Click Site Actions -> Edit in SharePoint Designer.

From there Click the “All Files” in the Navigation, then click “Workflows”
allfiles

workflows

Right-Click the workflow you would like to copy. And go to “Copy”

copyworkflow

Don’t close SharePoint Designer. Go to your destination site (wherever you want to move these puppies to). Go to Site Actions -> Edit in SharePoint Designer.

Go to All Files -> Workflows (**If you don’t have “Workflows” available to you, you can make a quick SharePoint Designer workflow on a random list and publish it, then restart SharePoint Designer.)

Right Click and choose “Paste”. The workflows should be there, but they are not associated with the list that you want since SharePoint recognizes and attaches workflows to Lists and Libraries using their ListID. We can change that through the .xoml.wfconfig.xml

In SharePoint Designer, go to “Lists and Libraries” in the navigation, then select the list or library you want to associate the workflow with. This should bring up the List/Library settings.

listview

The ListID is what you are looking for. Copy this. Ignore the brackets, Mine will be:

35DAE9D1-85F7-4C95-A155-09072263F146

Now let’s go back to the workflow you copied over earlier. Click the “All Files” again in the navigation, then click “Workflows”, then click the workflow name. This should bring you to the files associated to that workflow.
Right-Click the .xoml.wfconfig.xml and select Open With -> SharePoint Designer (Open as XML). This is what you get.

wfconfig

The highlighted part is what you are pasting that ListID to. Delete the ListID, and paste the ListID you copied earlier here. Save the file and close down out of SharePoint Designer completely. Then start SharePoint Designer back up and you should see the Workflow available in the “Workflows” section in the navigation. Open the workflow up and hit Publish to publish it to the destination site. You should be good to go from there! Enjoy!

Hidden folders in Explorer View


I noticed this morning that one of my users (actually would be several, but this is the first user I troubleshooted) had 3 folders missing from the explorer view of a document library. They were oddly named with the first character being an underscore(_).

So digging a little deeper, I smacked my forehead and remembered that underscore is Windows’ way of determining whether or not a folder should be hidden. So I copied the folders to my desktop, deleted the folders on SharePoint, renamed them without the (_)underscore, and put the files back.

The user can now see the folders.

 

 

Discussion board threading in reverse chronological order


Your threading view should be set up as the following:

Columns:

  • Threaded(threading)

Sort:

  • First sort by: Threading -> Show items in descending order
  • Then sort by: Created -> Show items in descending order
  • Uncheck “Sort only by specified criteria”

Folders:

  • Show all items without folders
  • Show this view: In folders of content type “Discussion”

This setup worked for me.

 

Note: Do NOT change the Folder Option: Show in this view to “In all folders” or “In the top-folder level” because it will throw an error when using discussion boards of type: 

Attempted to use an object that has ceased to exist. (Exception from HRESULT:
0×80030102 (STG_E_REVERTED))

 

Redirection Options with SharePoint Forms


Excerpt from http://info.kraftkennedy.com/blog/bid/102004/SharePoint-Redirection-Options-in-Upload-and-New-Item-Forms:

When you click “New Item” in any SharePoint list or “Upload” in any document library, SharePoint sends you to a standard form for creating the new item.  Behind the scenes, SharePoint also passes in two parameters to let the form know where to post the item and where to go after the item is posted.  By leveraging these two parameters in the URL, you can make a link anywhere that posts data to any list and sends you someplace else when finished.  This has come in handy for us when creating intranet home pages, as we can create a list of links to post data to custom lists, which sends the person back to the home page afterwards.  Otherwise, the person would end up in the root of the list or library they submitted the item to.  So we were able to easily meet a requirement that the person be directed back to the home page after submitting the item.

A SharePoint new item link is structured as follows:

https://intranet.doman.com/site/Lists/listname/NewForm.aspx?RootFolder=/site/Lists/listname&Source=https://intranet.domain.com

The two parameters of interest are RootFolder and SourceRootFolder tells SharePoint where to post the document.  If it is removed from the URL then SharePoint will post data to the root of the list where newform.aspx is located.  You could also specify the path to a subfolder there, and SharePoint would post to that subfolder.  Source tells SharePoint where to go when the posting is complete.  The source needs to be a place in the site collection.  In the example link above it is back to the home page.  If source is left out of the URL then SharePoint will just return you back to the root of the list afterwards.

This is big with DVWPs. I have several DVWP with HTML Form filters on them. The DVWP document library form doesn’t allow a new item unfortunately, so I can instead make a link to the upload.aspx of that document library, and after changes are complete, SharePoint sends the user right back to where they clicked that link.

A DVWP upload form would be nice. Does anyone know what Microsoft is doing about DVWP and document libraries? I wonder if SharePoint 2013 will be more integrated and more options through SP Designer.

Follow

Get every new post delivered to your Inbox.