Skip to main content
Hi All,

I seem to be really spamming the forums today - apologies to all but I have a lot to do, in not enough time, with not enough knowledge!!

My process is kicked off by an aspx smartform. One of the fields is "Due Date". I want to generate a reminder email before this due date is reached.

As the moment my C# for this server event looks like:

.Value.ToString()) .AddDays(- 5);
}


This is fine for the the hardcoded value of Reminder Date = (Due Date - 5 Days). However, I do not want the number of days to be hard coded.

So I added a K2DropDownList to my form with 1 day, 2 days, 3 days etc (with value set to 1,2,3,etc). This is bound to a process instance datafield called "DaysTillReminder" (type: integer).

But I can't seem to get the code right. I want:

[TaskReminderDate] = [Due Date] - [DaysTillReminder]

Can anyone help me out with the code here? Or maybe suggest a better way. Many thanks!!

Kind regards,

Rich
System.DateTime end = System.DateTime.Parse(dateStr);
end.AddDays(-5);
K2.SetEscalationRule(end);
Thanks for the tip ashley, unfortunately I don't quite follow.

I want to to calculate the [taskreminderdate] by subtracting the number of days held in [DaysTillReminder] from [Due Date].

Does that make sense?

Many thanks,

Rich
icon-quote.gifashley@k2workflow.com:

// Create a date time object called "end" that uses the Parse contructor on a string called dateStr, this string holds the due date
System.DateTime end = System.DateTime.Parse(dateStr);

//remove 5 days from this date
end.AddDays(-5);
//set the escalation rule to the modified date
K2.SetEscalationRule(end);


Sorry, I didn't notice in your original post that you're not using Escalations here.

What you probably want to do is add a send email escalation. The escalation rule will contain code similar to the above. And the Escalation Action will send the email.

no need to save this value to a datafield for later coding.. Studio does the hard work for you ;-)

You can also subtract a TimeSpan from a DateTime object.

DateTime = dt.Parse(strDateTime);
TimeSpan ts = new TimeSpan(2,0,0,0);
dt = dt - ts;
K2.SetEscalationRule(dt);

If you really did want to set the datafield to due date - 5 days you could use the various .To functions .ToLongDateString for example.

Hope this helps
Thanks Ashley, that is much more clear.

However - what I really need is for this to be controlled by the user.

So, on the original form the user sets [start date] and [due date].

They also specify "send reminder email X days before [due date]"

I pass X into a K2 Process Datafield.

Can I use this method with email escalations?

Many thanks again for your time and support,

Rich
yes. you can do this with escalations.

just take the due date. use the Parse constructor to create a date time object fromt he due date string. get an integer from the drop down list for how many days to set the reminder.
Perfect! Thanks again for your time and patience.

Cheers,

Rich

Reply