[英]Set null/nothing to lookup field
I need to set null/nothing to lookup field in crm 2011, using c# code.我需要使用 c# 代码在 crm 2011 中将 null/nothing 设置为查找字段。 I'm using early bound entities.
我正在使用早期绑定实体。
My method has parameters: public Guid ZalozeniPodporSmluvy(String name, Guid programid)我的方法有参数:public Guid ZalozeniPodporSmluvy(String name, Guid programid)
When i try to pass Guid - programid = Guid.Empty to EntityReference of programid property, i get error:当我尝试将 Guid - programid = Guid.Empty 传递给 programid 属性的 EntityReference 时,出现错误:
Pgrlf_pojistna_smlouva With Id = 00000000-0000-0000-0000-000000000000 Does Not Exist
Pgrlf_pojistna_smlouva 与 Id = 00000000-0000-0000-0000-000000000000 不存在
The same i get when i try directly assign null -当我尝试直接分配 null 时,我得到的结果相同 -
pgrlf_programid = new EntityReference("pgrlf_program", null)
{
supported_contracts PodporSmlouva = new supported_contracts()
{
name = name,
programid = new EntityReference("program", programid),
};
PodporSmlouva.Id = _proxy.Create(PodporSmlouva);
var entity = _proxy.Retrieve("supported_contracts", PodporSmlouva.Id, new ColumnSet(true));
return entity.Id;
}
Sometimes i need to pass exact guid to this method and make a reference between two entities and sometimes not.有时我需要将精确的 guid 传递给此方法并在两个实体之间进行引用,有时则不需要。 How can i pass nothing to programid and create no reference?
我怎样才能不向 programid 传递任何内容并且不创建任何引用?
This will do the trick.这将解决问题。
programid = null;
If you want conditional do something like如果你想有条件地做类似的事情
if(condition staisfies){
programid = null;
}else{
programid = new EntityReference("program", programid)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.