none
SharePoint Designer 2010 Workflow does not work after import to visual studio

    Question

  • Hello!

    First off, the reason for importing my SPD workflows to visual studio is to try to make them NOT deploy globally in the farm, just to a specific Web Application, is this possible? (Reusable wf, saved as .wsp) If so, the problem/question below is not so important...

    The short story is what the subject says, here a little longer: For a project im currently working on I have a custom list (custom contentype, site columns, list definitons, new/edit/display form) and to this I created 2 workflows in SPD 2010 (Reusable workflows). The workflows both send out e-mails dependent on specific values selected on item created in my custom list with custom content typ. Bot these workflows work nicely when deploying the .wsp directly after saving them from SPD.

    When I import the workflows to visual studio, one of the workflows does not work (not from visual studio deploy or scripted deploy). This is what strikes me as odd. I do no changes to the workflow in visual studio and the "it doesn´t work part" is that the workflow fails with "The e-mail message cannot be sent. Make sure the e-mail has a valid recipient.".  So, there is something wrong with the email address... probably it´s not getting populated anymore for some reason. The e-mail recipient I get from another list (custom list included in my vs solution) that holds data for a dropdown  (lookup) in my custom list with the workflow runs, as well as the e-mail adresses, i.e.:

    Data source: Board nbr (a list that is not the list where the workflow runs)

    Field from source: Manager (a field in list Board nbr)

    Return as: e-mail

    these choices pop up a new lookup:

    Field: Title

    Value: CurrentItem: Board nbr - this I get from:

    Data Source: CurrentItem

    Field from source: Board nbr (the value in board nbr dropdown in the list where workflow runs)

    Return as: Lookup (as text)

    Anyone that have run in to something like this before? Visual studio must be doing something fishy with the workflow, or maybe the lookups to find the e-mail is not imported correct to visual studio...?

    Regards // CSR

    Monday, March 05, 2012 9:35 PM

Answers

  • Hi CSR.

    What if you (test only) try to upload the wsp manually to a site collection Solution Gallery and activate it there? Will that work?

    Regards


    Thomas Balkeståhl - Technical Specialist - SharePoint - http://blog.blksthl.com
    Download the SharePoint Branding Project here

    • Marked as answer by CSR81 Wednesday, March 07, 2012 11:57 AM
    Wednesday, March 07, 2012 8:31 AM
  • Hi CSR.

    Glad I could help, appreciate the feedback!
    If the solution gallery approach is viable to you, then why not deploy it to the site collection using powershell? ;-)

    Find out how here:

    Deploy a workflow as a WSP file (SharePoint Server 2010)
    http://technet.microsoft.com/en-us/library/ff608051.aspx

    Its basically the same as a farm solution:
    Add-SPUserSolution -LiteralPath <LiteralPath> -Site <SiteURL>
    Install-SPUserSolution –Identity <Solution> –Site <SiteURL>
    Enable-SPFeature -Identity <Feature> -Url <URL>

    Good luck!

    @CSR: I would appreciate it a lot if you could provide me with feedback on the Branding Project Template when you have tried it out.

    Regards


    Thomas Balkeståhl - Technical Specialist - SharePoint - http://blog.blksthl.com
    Download the SharePoint Branding Project here

    • Marked as answer by CSR81 Thursday, March 15, 2012 11:37 AM
    Wednesday, March 07, 2012 12:08 PM

All replies

  • Hi.

    I'll just answer the easy one first:
    'just to a specific Web Application, is this possible?'
    Yes, set the scope of your workflow Feature to 'WebApplication' This will make it available only to the web app where you have choosen to deploy it. You can also restrict it to a site colllection(site) or a specific subweb(web).

    For the actual question, try debugging it and see what value it tries to use as emailaddress, sounds to me that it gets the wrong value...

    Regards


    Thomas Balkeståhl - Technical Specialist - SharePoint - http://blog.blksthl.com
    Download the SharePoint Branding Project here

    • Proposed as answer by Varun Malhotra Tuesday, March 06, 2012 5:48 AM
    • Unproposed as answer by CSR81 Tuesday, March 06, 2012 10:04 PM
    Monday, March 05, 2012 11:01 PM
  • Hi, and thanks for the reply.

    Regarding the "first" question/answer; In that case i did not import the workflow to visual studio at all, just had a .wsp saved as template from SPD, so I cant change scope of the feature in that case. (I thought it would be easier to create the workflows in SPD only and deploy their .wsp, but they are globally deployed, and the request came that this was not alllowed). Also: one can´t deploy a wsp to a specific web application if the solution "does not contain WebApplicationResources" i think.

    About question 2: Will try to debug and see what the value is, but not sure where to put my break point, my code behind (.xoml.cs) has no code.. I did not create any customizations for the workflow in visual studio, just imported it.

    Regards //CSR

    Tuesday, March 06, 2012 8:24 AM
  • No luck so far on this. Cant seem to figure out why the workflow (probably) gets wrong value for e-mail when it´s imported to visual studio, and how this could be fixed. No debugging success either, since I don´t really have any code to debug... Will probably abandon this and try something else. To bad that a more complex SPD workflow (Lookups) can´t be easily imported with same functionality to VS. Thanks for your efforts though.

    Regards //CSR

    Tuesday, March 06, 2012 10:03 PM
  • Hi CSR,

    Thanks for your post!

    A SharePont designer workflow will not deploy globally in the farm,neither the web application, it will only be published within a web scope or site collection scope(globally publish), so you do not need to import it to visual studio.

    Thanks,
    Simon


    Simon Huang

    TechNet Community Support

    Wednesday, March 07, 2012 6:09 AM
  • Hi Simon, and thanks for the reply.

    I´m not sure that it is so. Maybe I should explain more about my deployment scenario: I have my workflow wsp, saved as templates from SPD. These .wsp are deployed to my server with a deployment script (PowerShell). If you try to specify the -WebApplication parameter in the "Install-SPSolution" function in PowerShell, the script fails due to that my wsp does not contain "WebApplication Resources" (Web parts, etc), so I can´t specify a web application in the script.

    When I deploy my .wsp, it is "Globally deployed" when I look at it in CA/Farm solutions. Also this feature is available on sites in other Web Applications in the farm. The deployment also cause all Web Applications in the farm to be recycled...(According to the ULS log) this is not acceptable in my case, and is what I´m trying to avoid...

    Regards //CSR

    Wednesday, March 07, 2012 8:25 AM
  • Hi CSR.

    What if you (test only) try to upload the wsp manually to a site collection Solution Gallery and activate it there? Will that work?

    Regards


    Thomas Balkeståhl - Technical Specialist - SharePoint - http://blog.blksthl.com
    Download the SharePoint Branding Project here

    • Marked as answer by CSR81 Wednesday, March 07, 2012 11:57 AM
    Wednesday, March 07, 2012 8:31 AM
  • Hi Thomas!

    This is actually not a bad approach at all! I tested it out and it worked as expected (feature only available in the specific site collection, no other web application recycles what I can see and of course no "globally deployed" in CA since its not deployed at that level). I will see if this deploy solution is possible to to instead of the scripted approach for my scenario. I will mark your suggestion as Answer Thomas because it actually solves my stated problem! Many thanks for the replies all!

    OT: @Thomas: I checked out your SharePoint Branding project template today as well, looks interesting and will dig deeper and try it out on another project! Good work!

    Regards //CSR

    Wednesday, March 07, 2012 11:57 AM
  • Hi CSR.

    Glad I could help, appreciate the feedback!
    If the solution gallery approach is viable to you, then why not deploy it to the site collection using powershell? ;-)

    Find out how here:

    Deploy a workflow as a WSP file (SharePoint Server 2010)
    http://technet.microsoft.com/en-us/library/ff608051.aspx

    Its basically the same as a farm solution:
    Add-SPUserSolution -LiteralPath <LiteralPath> -Site <SiteURL>
    Install-SPUserSolution –Identity <Solution> –Site <SiteURL>
    Enable-SPFeature -Identity <Feature> -Url <URL>

    Good luck!

    @CSR: I would appreciate it a lot if you could provide me with feedback on the Branding Project Template when you have tried it out.

    Regards


    Thomas Balkeståhl - Technical Specialist - SharePoint - http://blog.blksthl.com
    Download the SharePoint Branding Project here

    • Marked as answer by CSR81 Thursday, March 15, 2012 11:37 AM
    Wednesday, March 07, 2012 12:08 PM
  • Yes, that seemed to be a very viable approach for me... why didn´t I see that one.. :-) Ended up with editing my powershell script for these solutions to use Add-SpUserSolution etc. and so far so good! I mark your last reply as answer as well, as it in the end was what i used. Thanks again!

    Also, started testing out your Branding Temlplate, and so far so good here as well in my opinion. Will add comments, feedback if such on your blog or the download site at visualstudiogalleries.

    Regards // CSR

    Thursday, March 15, 2012 11:37 AM