For those of you who created a custom action, you may or maynot have noticed that when you do a custom activity, configure it to use Lookup fields on field configured as DesignerType="StringBuilder" and instead of field value you get [%_x005f_String0%] you need to "tell" SharePoint to replace your tokens (look up fields) with the actual values on that workflow.
A good example was when I was trying to develop an action that will work like the "send email" action, only included some changes.
I got this error in the "body" field of the email i wanted to send.
The solution is rather easy to implement and consists of 2 steps:
1 - First you have to define a new property to your activity - the workflow context:
public static DependencyProperty __ContextProperty = DependencyProperty.Register("__Context", typeof(WorkflowContext), typeof(EmailActivity));
[ValidationOption(ValidationOption.Optional)]
public WorkflowContext __Context
{
get
{
return (WorkflowContext) base.GetValue(__ContextProperty);
}
set
{
base.SetValue(__ContextProperty, value);
}
2 - Second you will have to your Execute method:
protected override ActivityExecutionStatus Execute(ActivityExecutionContext provider){
Activity parent = provider.Activity;
while (parent.Parent != null)
{
parent = parent.Parent;
}
string returnValue = Helper.ProcessStringField(stringToProcess, parent, this.__Context));
}
You don't want to know how I learned that, so don't ask...
1 comment:
Thank's. It works.
Post a Comment