You are viewing limited content. For full access, please sign in.

Question

Question

Conditional Statement in Email Activity

asked on May 2, 2017 • Show version history

Good morning,

For simplicity purpose let's say that I have a form that has two radio buttons. One radio button assigns the value of 0 and the other one as 1. Their display is No and Yes.

I want to keep the 0 and 1 as the values because I insert this into a database, I'm using lookup rules to swap the radio buttons also when loading and all works just fine.

However, I have a workflow that has an Email activity that grabs the value submitted from the radio buttons and says something like. You chose "1" or You chose "0".  

I want for the email message to say: You chose "Yes" or You chose "No". I was hoping that I didn't have to mess with hidden fields since I'm already using many to swap the radio buttons back and forth. In a real scenario I have multiple questions with this radio buttons and it would be too much work to create a case for each.

Is there a way to simply program something on the Email Activity (or prior to getting to it) so that when the field is retrieved if it reads 0 to convert it to "No" and if it reads 1 to convert it to "Yes"?

I tired the conditional branch but it only drives the flow into that branch, it doesn't allow you to set new values or something.

Any ideas?

0 0

Answer

SELECTED ANSWER
replied on May 2, 2017

I actually found that I can do something with the Assign Token Activity. I tired the screenshot below and it worked. It's still some work, but I think it's more maintainable. Please let me know if there is a better way.

1 0

Replies

replied on May 2, 2017

I would love to see the ability added to do conditions within an email message itself.

0 0
replied on May 2, 2017

Assign Tokens in a conditional activity works. If you want it in one single activity, Token Calculator has a "substitute" function.

0 0
replied on May 5, 2017 • Show version history

I'd like to pitch in what I ended up doing. Keep in mind that I'm a total newbie in C# and SDK completely, but knew what I wanted to accomplish so I flirted a little with the SDK Script Activity.

The result was a simple code that transforms the 0s in NOs and the 1s in YESses. I wanted to keep the logic in one place, but using the Assign Token Activity had made me add 8 conditional branches, each one with an Assign Token Activity and I thought it was a little too much to maintain.

I digged a little into the SKD Script Activity just to get me what I needed and send out the email. Below is an example. Where I struggled the most was in finding how to assign the Business Process Variable inside the script because I couldn't find a straight answer in any of the LF posts. Once I found how to get them, the rest was just like any other language. I'm posting this for the totally SDK newbie like myself. Hope it helps someone.

namespace WorkflowActivity.Scripting.SDKScriptEmail
{
    using System;
    using System.Web;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;
    using System.Text;
    using Laserfiche.RepositoryAccess;
    using System.Net.Mail;
    using Laserfiche;

    /// <summary>
    /// Provides one or more methods that can be run when the workflow scripting activity is performed.
    /// </summary>
    public class Script1 : RAScriptClass100
    {
        /// <summary>
        /// This method is run when the activity is performed.
        /// </summary>
        protected override void Execute()
        {
            // Write your code here. The BoundEntryInfo property will access the entry, RASession will get the Repository Access session


//'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
string QExport = GetTokenValue("QueryDatatblDataClassification_hasExportControlledItems").ToString();
int QExportInt = Convert.ToInt32(QExport);

if (QExportInt == 0) {
    QExport = "No";
}
else
   {
    QExport = "Yes";
}

            // Command line argument must the the SMTP host.
            SmtpClient client = new SmtpClient();
            client.Port = 25;
            client.Host = "smtp.yourdomain.com";
            //client.EnableSsl = true;
            client.Timeout = 10000;
            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            client.UseDefaultCredentials = false;
            client.Credentials = new System.Net.NetworkCredential("from_email@yourdomain.com","");

            MailMessage mm = new MailMessage("from_email@yourdomain.com", "to_email@yourdomain.com", "Submect", "message");
            mm.BodyEncoding = UTF8Encoding.UTF8;
            mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
            mm.IsBodyHtml = true;

            client.Send(mm);

        }
    }
}

 

You are not allowed to follow up in this post.

Sign in to reply to this post.