Thursday, November 29, 2007

Lookup fields in custom activity and [%_x005f_String0%]

If 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 process this value with this function: public static string ProcessStringField ( string str, Activity activity, WorkflowContext context ) Here is a code sample:

//...
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); }
}
//...
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));
}

It seems that if you don't have WorkflowContext you can pass null
string returnValue = Helper.ProcessStringField(stringToProcess, parent, this.__Context));

1 comment:

Indrajeet Kumpavat said...

Thanks Sebastian.

This helped me a lot.

Regards,
Indrajeet.
blogindrajeet.blogspot.com