【问题标题】:Can I get the GUID of a record in a CRM workflow?我可以在 CRM 工作流程中获取记录的 GUID 吗?
【发布时间】:2010-03-31 09:26:00
【问题描述】:

我需要从 Dynamics CRM 4 工作流程中获取记录的 GUID。这是在工作流执行期间创建的记录。我想编写一个 w/f 程序集,它接受查找并返回一个包含 GUID 的字符串(这对我的目的来说已经足够了)。但是,程序集中的 Lookup 必须指定实体的类型。由于许多实体的需求已经存在,并且对于许多其他将由客户在不通知的情况下创建的实体,这对我不起作用。

有没有什么方法可以轻松地做到这一点,或者有什么方法可以为接受任何实体类型的工作流程序集创建查找参数?

【问题讨论】:

    标签: workflow-foundation dynamics-crm dynamics-crm-4 crm


    【解决方案1】:

    最好的办法是创建一个帖子创建插件,将 GUID 设置为自定义字段 (new_myguid),然后您的工作流程将能够在执行后立即读取该字段。

    【讨论】:

    • 是的,这就是我最后的选择。
    【解决方案2】:

    您是正确的,您无法从工作流设计器本地访问实体 ID,并且自定义活动将被限制为每个输入属性的单个实体。

    您可以实施 Focus 的建议,但您还需要每个实体上的自定义属性和插件。

    我想我可能会做一个自定义活动,并有多个输入属性,所有输出到一个输出属性。

    类似这样的:

    [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;
    }
    

    【讨论】:

    • 这行不通,因为实体不会提前知道。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-04
    • 1970-01-01
    • 2021-03-18
    • 2021-11-06
    相关资源
    最近更新 更多