简体   繁体   English

如何获取 C# 中 IOrg.associate 的查找字段的 GUID?

[英]How to get GUID of Lookup field for IOrg.associate in C#?

I've tried to get the GUID of a record using a lookup field value我尝试使用查找字段值获取记录的 GUID

var installationSiteEntity = new Entity("csp_installationsite");
var serviceSite = installationSiteEntity.GetAttributeValue<string>("cr3aa_servicesite");

Then I've used service.Associate("account", serviceSite, servicesiteOpp, newCollection);然后我使用service.Associate("account", serviceSite, servicesiteOpp, newCollection);

But I get the error it can't convert string to guid, how do I get the GUID lookup value from this field?但是我得到它不能将字符串转换为 guid 的错误,我如何从这个字段中获取 GUID 查找值?

Try getting it as an entity reference尝试将其作为实体参考

var serviceSite = installationSiteEntity.GetAttributeValue<EntityReference>("cr3aa_servicesite");
service.Associate("account", serviceSite.id, servicesiteOpp, newCollection);

or covert the string back to a guid.或将字符串转换回 guid。

service.Associate("account", new Guid(serviceSite), servicesiteOpp, newCollection);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM