我试图使用以下代码创建设施/设备,但我收到一条错误消息,提示“业务单位 ID 不能设置为 NULL”
我在我的 crm 2016 中只创建了一个业务部门这是我的代码:
string fetchBU = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
<entity name='businessunit'>
<attribute name='name' />
<attribute name='address1_telephone1' />
<attribute name='websiteurl' />
<attribute name='parentbusinessunitid' />
<attribute name='businessunitid' />
<order attribute='name' descending='false' />
</entity>
</fetch>";
EntityCollection resultequipments = _orgService.RetrieveMultiple(new FetchExpression(fetchBU));
if (resultequipments.Entities.Count > 0)
{
Guid BuId;
BuId = (Guid)resultequipments.Entities[0]["businessunitid"];
Entity equipment = new Entity("equipment");
equipment["name"] = "test";
equipment["businessunitid"] = BuId;
_orgService.Create(equipment);
Console.WriteLine("Facility successfully created");
}
提前致谢。