Вы правы, что вы не можете получить доступ к идентификатору сущности из конструктора рабочего процесса изначально и что настраиваемое действие будет ограничено одной сущностью на входное свойство.
Вы можете реализовать предложение Фокуса, но вам понадобится этот пользовательский атрибут и плагин также для каждой сущности.
Я думаю, что я, вероятно, выполнил бы пользовательское действие и имел бы несколько входных свойств, которые все выводили бы в одно выходное свойство.
Примерно так:
[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;
}