Plugins 来自相关实体的插件更新字段

Plugins 来自相关实体的插件更新字段,plugins,dynamics-crm,crm,Plugins,Dynamics Crm,Crm,我想构建一个插件,用于从相关实体更新字段。 关于实体协议,我有两个字段:字段A(查找账户)和字段B(查找联系人) 我必须检查Account(字段A)中的选项集字段是否是一个特定值,然后更新Contact(字段B)中的选项集字段 就这些。谢谢 实体协议=(实体)上下文。输入参数[“目标”];//这是启动插件的目标实体。 Entity agreement = (Entity)context.InputParameters["Target"]; // this is your target entit

我想构建一个插件,用于从相关实体更新字段。 关于实体协议,我有两个字段:字段A(查找账户)和字段B(查找联系人)

我必须检查Account(字段A)中的选项集字段是否是一个特定值,然后更新Contact(字段B)中的选项集字段

就这些。谢谢

实体协议=(实体)上下文。输入参数[“目标”];//这是启动插件的目标实体。
Entity agreement = (Entity)context.InputParameters["Target"]; // this is your target entity from which plugin is firing.

// Now do whatever your check you wish to perform

// once you are ready to update lookupAccount Record below code will work

  Entity lookupAccount = new Entity();
                    lookupAccount.LogicalName = "account";
                    lookupAccount.Id = agreement.GetAttributeValue<EntityReference>("field A").Id;
                    lookupAccount["optionSetFieldToUpdate"]= new OptionSetValue(1234);

                    orgService.Update(lookupAccount);



// In similar way you can perform update for ook-up Contact)


 Entity lookupContact = new Entity();
                    lookupContact.LogicalName = "contact";
                    lookupContact.Id = agreement.GetAttributeValue<EntityReference>("field B").Id;
                    lookupContact["optionSetFieldToUpdate"]= new OptionSetValue(1234);

                    orgService.Update(lookupContact);
//现在,执行您希望执行的任何检查 //一旦您准备好更新lookupAccount记录,下面的代码将起作用 实体查找帐户=新实体(); lookupAccount.LogicalName=“account”; lookupAccount.Id=agreement.GetAttributeValue(“字段A”).Id; lookupAccount[“optionSetFieldToUpdate”]=新的OptionSetValue(1234); orgService.Update(查找帐户); //以类似的方式,您可以执行ook up联系人的更新) 实体查找联系人=新实体(); lookupContact.LogicalName=“contact”; lookupContact.Id=agreement.GetAttributeValue(“字段B”).Id; lookupContact[“optionSetFieldToUpdate”]=新的OptionSetValue(1234); orgService.Update(查找联系人);
是的,这是可能的。你有什么问题?到目前为止,您尝试了什么?我不知道如何从查找实体更新该字段。