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.

01namespace WorkflowActivity.Scripting.SDKScriptEmail
02{
03    using System;
04    using System.Web;
05    using System.Collections.Generic;
06    using System.ComponentModel;
07    using System.Data;
08    using System.Data.SqlClient;
09    using System.Text;
10    using Laserfiche.RepositoryAccess;
11    using System.Net.Mail;
12    using Laserfiche;
13 
14    /// <summary>
15    /// Provides one or more methods that can be run when the workflow scripting activity is performed.
16    /// </summary>
17    public class Script1 : RAScriptClass100
18    {
19        /// <summary>
20        /// This method is run when the activity is performed.
21        /// </summary>
22        protected override void Execute()
23        {
24            // Write your code here. The BoundEntryInfo property will access the entry, RASession will get the Repository Access session
25 
26 
27//'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
28string QExport = GetTokenValue("QueryDatatblDataClassification_hasExportControlledItems").ToString();
29int QExportInt = Convert.ToInt32(QExport);
30 
31if (QExportInt == 0) {
32    QExport = "No";
33}
34else
35   {
36    QExport = "Yes";
37}
38 
39            // Command line argument must the the SMTP host.
40            SmtpClient client = new SmtpClient();
41            client.Port = 25;
42            client.Host = "smtp.yourdomain.com";
43            //client.EnableSsl = true;
44            client.Timeout = 10000;
45            client.DeliveryMethod = SmtpDeliveryMethod.Network;
46            client.UseDefaultCredentials = false;
47            client.Credentials = new System.Net.NetworkCredential("from_email@yourdomain.com","");
48 
49            MailMessage mm = new MailMessage("from_email@yourdomain.com", "to_email@yourdomain.com", "Submect", "message");
50            mm.BodyEncoding = UTF8Encoding.UTF8;
51            mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
52            mm.IsBodyHtml = true;
53 
54            client.Send(mm);
55 
56        }
57    }
58}

 

You are not allowed to follow up in this post.

Sign in to reply to this post.