locked
Accept Multiple Lines of Text InArgument in Custom Workflow Activity? RRS feed

  • Question

  • I am working on a custom workflow activity that will create appointments in an outlook calendar and I am having trouble finding the correct type to use for Multiple Lines of Test.  

    I currently have 

    [Input("Appointment Body")]
    public InArgument<String> Body { get; set; }

    This shows up as a single line of text parameter in crm.  Can someone please direct me to the correct syntax to accept a multiple lines of text property?

    Thursday, October 17, 2013 2:28 PM

Answers

  • I was able to resolve this issue by first converting the body string to html.  Thank you for your help.
    • Marked as answer by Jason_Sanders Thursday, October 17, 2013 6:07 PM
    Thursday, October 17, 2013 6:06 PM

All replies

  • Hi Jason,
    as far as I know there isn't a way to show a multiple line of text as input for a custom workflow activity, string only show the single line.

    My blog: www.crmanswers.net

    Thursday, October 17, 2013 3:02 PM
  • I think I may be asking the wrong question then.  I thought that this was the reason the text was loosing its formatting when working with EWS but writing the string out to a text file preserves the formatting.  When using another  application the appointment body has the correct formatting.  But, any string from the CRM activity to EWS will lose its formatting in the appointment body.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    using System.Activities;
    using Microsoft.Xrm.Sdk;
    using Microsoft.Xrm.Sdk.Workflow;
    
    using Microsoft.Exchange.WebServices.Data;
    
    namespace AppointmentCRMActivity
    {
        public class AppointmentActivity : CodeActivity
        {
            [Input("Appointment Start Date")]
            public InArgument<DateTime> StartDate { get; set; }
    
            [Input("Appointment Finish Date")]
            public InArgument<DateTime> EndDate { get; set; }
    
            [Input("Appointment Subject")]
            public InArgument<String> Subject { get; set; }
    
            [Input("Appointment Body")]
            public InArgument<String> Body { get; set; }
    
            [Input("Calendar SMTP Address")]
            public InArgument<String> CalendarAddress { get; set; }
    
            protected override void Execute(CodeActivityContext context)
            {
                try
                {
                    ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
                    service.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
                    service.AutodiscoverUrl(CalendarAddress.Get(context), validateRedirectionCallback);
    
                    FolderId folderId = new FolderId(WellKnownFolderName.Calendar, (new Mailbox(CalendarAddress.Get(context))));
                    Appointment appt = new Appointment(service);
    
                    appt.Subject = Subject.Get(context);
                    appt.Body = Body.Get(context);
                    appt.Start = StartDate.Get(context);
                    appt.End = EndDate.Get(context);
    
                    appt.Save(folderId, SendInvitationsMode.SendToNone);
                }
                catch (Exception ex)
                {
                    System.IO.TextWriter tw = System.IO.File.AppendText("C:\\jasons\\Log.txt");
                    tw.WriteLine("------------" + DateTime.Now.ToString() + "------------");
                    tw.Write(ex.Message);
                    tw.WriteLine("-------------------------------------------------------");
                    tw.Close();
                }
            }
    
            static bool validateRedirectionCallback(String redirectionUrl)
            {
                return true;
            }
        }
    }

    Thursday, October 17, 2013 3:45 PM
  • I was able to resolve this issue by first converting the body string to html.  Thank you for your help.
    • Marked as answer by Jason_Sanders Thursday, October 17, 2013 6:07 PM
    Thursday, October 17, 2013 6:06 PM