You are right that you cannot access an entity id from the workflow designer natively and that a custom activity would be limited to a single entity per input property.
You could implement Focus's suggestion, but you'd need that custom attribute and plugin on each entity as well.
I think I'd probably do a custom activity and have multiple input properties that all output to a single output property.
Something like this:
[CrmInput("Contact")]
[CrmReferenceTarget("contact")]
public Lookup Contact
{
get { return (Lookup)GetValue(ContactProperty); }
set { SetValue(ContactProperty, value); }
}
public static readonly DependencyProperty ContactProperty =
DependencyProperty.Register("Contact", typeof(Lookup), typeof(YourActivityClass));
[CrmInput("Account")]
[CrmReferenceTarget("account")]
public Lookup Account
{
get { return (Lookup)GetValue(AccountProperty); }
set { SetValue(AccountProperty, value); }
}
public static readonly DependencyProperty AccountProperty =
DependencyProperty.Register("Account", typeof(Lookup), typeof(YourActivityClass));
[CrmOutput("Entity ID")]
public string EntityID
{
get { return (string)GetValue(EntityIDProperty); }
set { SetValue(EntityIDProperty, value); }
}
public static readonly DependencyProperty EntityIDProperty =
DependencyProperty.Register("EntityID", typeof(string), typeof(YourActivityClass));
protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
{
Lookup[] lookups = new[] { Contact, Account };
foreach (Lookup lookup in lookups)
{
if (lookup != null && lookup.Value != Guid.Empty)
{
EntityID = lookup.Value.ToString();
break;
}
}
return ActivityExecutionStatus.Closed;
}