locked
Problem with Custom WorkFlow Action RRS feed

  • Question

  • we have developed custom workflow action , which gives ability to pick the from address from which email should be sent.

     

    it was working in Stage and Dev tier fine , and when i deployed on prod.

    through designer i can see the workflow action but it was not able to load in designer view.

    i digged in to logs and i found their was error which is

    Error:  Could not deserialize object. The type 'Extended.Actions.SendMailActivity' could not be resolved

    then i compared web.configs of all the 3 wfe servers  and in 2 servers it was missing <AuthersationTypes> of custom workflow action.

    So i manually updated the other 2 web.configs and added the <AuthorizationType>.

    after the above change i can load the action in designer view but still its not working.

    how should a custom workflow action should be deployed?

     

    any thoughts?

    Thanks in advance

     



    Share Knowledge and Spread Love!
    Monday, May 23, 2011 5:27 PM

Answers

  • thanks matthew .

    but i figured out what was the probem.

    while testing the workflows on prod , i was giving my AD account to send an email  something like the domain\myname.

    which is why it is unable to parse the email address.

     

    then i tired  passing the actual email address to workflow variable and it works like charm.

     

    Thanks again


    Share Knowledge and Spread Love!
    • Marked as answer by Porter Wang Tuesday, May 31, 2011 3:08 AM
    Thursday, May 26, 2011 1:02 PM

All replies

  • There are two methods you can use to modify the web.config file.

    1. Create a supplemental .config file
    2. Use the SPWebConfigModification class in a feature reciever to make the modifications

    For more information about these two methods see: http://msdn.microsoft.com/en-us/library/ms460914.aspx

    Monday, May 23, 2011 8:11 PM
  • You'll need to create an empty sharepoint project for the deployment.

    http://perrystechblog.blogspot.com/2010/08/create-custom-workflow-action-in.html

    To update the web.config, you can create a feature event receiver and hook up the FeatureActivated event. Then place your code to update the web.config there. To update web.config, I suggest using SPWebConfigModification because the update is relatively a small portion. Please notice that you'll need to remove the new added entry in the FeatureDeactivating otherwise you'll end up getting lots entries after a couple of re-deployment.

            public static void RemoveConfigModificationByOwner(string owner)
            {
                SPWebService myService = SPWebService.ContentService;

                Collection<SPWebConfigModification> modsCollection = myService.WebConfigModifications;

                int count = modsCollection.Count;

                for (int i = count - 1; i >= 0; i--)
                {
                    SPWebConfigModification mod = modsCollection[i];
                    if (mod.Owner == owner)
                    {
                        modsCollection.Remove(mod);
                    }
                }

                myService.Update();
                myService.ApplyWebConfigModifications();
            }


    Perry Zhou
    Toronto SharePoint Consultant
    blog email linkedin
    Monday, May 23, 2011 10:20 PM
  •  

    After enabling verbose logging for workflow infrastructure on prod site , am able to collect below error?

     w3wp.exe (0x20A8) 0x1EE0 SharePoint Foundation Workflow Infrastructure 98d4 Unexpected System.FormatException: The specified string is not in the form required for an e-mail address. at System.Net.Mime.MailBnfHelper.ReadMailAddress(String data, Int32& offset, String& displayName) at System.Net.Mail.MailAddressCollection.ParseValue(String addresses) at AN.Actions.SendMailActivity.SendEmail(Activity parent) at AN.Actions.SendMailActivity.Execute(ActivityExecutionContext executionContext) at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(T activity, ActivityExecutionContext executionContext) at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(Activity activity, ActivityExecutionContext executionContext) at System.Workflow.ComponentModel.ActivityExecutorOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime) at System.Workflow....'
    can any one know what this error means?
    Thanks in Advance

    Share Knowledge and Spread Love!
    Wednesday, May 25, 2011 6:38 PM
  • This error is thrown because one of the Email address that the code is trying to add to the email address list is not in the correct format.  Did you guys build this solution or get it from a third party? If I had to guess, in your workflow somewhere you set who to send the email to and you need to ensure that value is being returned as an email address and not a user name (Ex. John.Doe@abc.com instead of Domain\John.Doe).

    if this activity is using the default send email window in SharePoint Designer when you select who to send the email to, if you are using a lookup there are three fields you have to enter: Data Source, Field from source, and Return field as.  Make sure the return field as is set to email address.

    If you have the ability to modify the Code for this activity in the section where you get the email addresses you can check to make sure they are in the correct format first before adding them to the collection.

    Wednesday, May 25, 2011 6:47 PM
  • Thanks Matthew for your reply

    the above solution works fine in Dev and Stage fine and am expecting issues in prod.

    its not an third party solution and its using default send email activity.

    below is the blog from where i built my solution

    http://sp2010notes.wordpress.com/2010/11/12/112/


    let me know , if you see anything wrong?

    Thanks again


    Share Knowledge and Spread Love!

    Wednesday, May 25, 2011 7:52 PM
  • In the place where you are getting the To addresses and CC addresses:

     for (int i = 0; i < To.Count; i++)
        {
         char[] delimiterChars = { ';', '#' };
         string text = To[i].ToString();
         string[] userTo = text.Split(delimiterChars);
         foreach (string s in userTo)
         {
          msg.To.Add(s);
         }

    The line: msg.To.Add(s) is probably where the exception is being thrown, because the value in the To and CC property could be a username if the user creating the workflow in SharePoint Designer is using a lookup value and it is not set to return as an email address. You might add a check of something like:

         for (int i = 0; i < To.Count; i++)
        {
         char[] delimiterChars = { ';', '#' };
         string text = To[i].ToString();
         string[] userTo = text.Split(delimiterChars);
         foreach (string s in userTo)
         {
             if (s.Contains("@")) --This is not a good way to validate the email address just an example
             {
                msg.To.Add(s);
              }
               else
              {
                msg.To.Add(Helper.ResolveToEmailName(__Context , s)); --Helper function to resolve user names in sharePoint to email addresses
              }
         }

    This could still throw an exception however if the Helper function cannot resolve the username to an email address. So you might want to add some additional checks around that.

    Wednesday, May 25, 2011 8:28 PM
  • thanks matthew .

    but i figured out what was the probem.

    while testing the workflows on prod , i was giving my AD account to send an email  something like the domain\myname.

    which is why it is unable to parse the email address.

     

    then i tired  passing the actual email address to workflow variable and it works like charm.

     

    Thanks again


    Share Knowledge and Spread Love!
    • Marked as answer by Porter Wang Tuesday, May 31, 2011 3:08 AM
    Thursday, May 26, 2011 1:02 PM
  • I made it working. Please refer following post

    http://pravin-pawar24.blogspot.in/2012/09/how-to-add-and-remove-entries-from_27.html

     

    Thanks,

    Pravin Pawar


    Thanks & Regards, Pravin Pawar

    • Proposed as answer by Pawar Pravin Friday, September 28, 2012 2:41 AM
    Friday, September 28, 2012 2:41 AM