使用CRM 4.0 Web服务设置BusinessEntity选择列表值 [英] Setting BusinessEntity picklist value using CRM 4.0 webservice

查看:93
本文介绍了使用CRM 4.0 Web服务设置BusinessEntity选择列表值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在CRM 4.0中创建一个ImportMap对象。我需要设置TargetEntity属性,它是一个Picklist值。 链接文本似乎暗示可以通过使用

I'm trying to create an ImportMap object in CRM 4.0. I need to set the TargetEntity property which is a Picklist value. link text seems to imply that it can be done by using

importmap map = new importmap();
map.name = "test map";
map.targetentity = new Picklist();
map.targetentity.name = "Contact"

但这似乎总是离开目标实体属性为null。

but this always seems to leave the target entity property as null.

有什么想法吗?

推荐答案

如果它是一个选择列表,则必须提供索引值。假设您有一个名为TargetValues.Contact的枚举,其值为1,则它将像这样:

If its a pick list, you will have to provide the index value. Assuming that you have an enum called TargetValues.Contact having value 1, then it would go like:

map.targetentity = new Picklist();
//map.targetentity.name = "Contact"
map.targetentity.Value = Convert.ToInt32(TargetEntities.Contact);

-编辑-

I相信对于您要实现的目标,您将必须以某种方式检索目标实体,然后您才能枚举它们。

I believe for what you are trying to achieve you will have to somehow retrieve the target entity and only then you will be able to enumerate them.

看到此,可能会有所帮助。

如果上面没有用,那么下面是您的操作方法:

If above is of no use, then following is how you can do it:


  1. 从用户界面打开选择列表,记下索引数及其对应的值。

  2. 在代码中创建一个枚举,并分配这些值/索引。

  3. 在运行时使用枚举(如上例所示)来设置选择列表。

但是随后索引可能会在一段时间内发生变化,因此在这种情况下,您可以使用这些值/索引创建枚举xml,并在运行时加载它们。但是这种方法的问题在于:

But then somehow indices may change over a period of time, so in that case you can create an enumerated xml with those values/indices, and load them on runtime. But the problem with this approach is that:


  1. 每当有人要更改索引时,这是非常罕见的,管理员还应该拥有更改XML文件。

  2. 加载外部xml文件是一项开销。

不-很好的方法,但是要紧迫最后期限,这是您可以做的;这永远不会中断或引起麻烦。只是xml加载部分不好。

Not-so-good approach, but running against a ticking deadline this is what you can do; this is never going to break or cause trouble. Just that xml loading part is not good.

顺便说一句,如果您要通过CRM SDK,则会发现类似的示例。

Btw, if you would go through the CRM SDK, you will find the examples of similar sort.

这篇关于使用CRM 4.0 Web服务设置BusinessEntity选择列表值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆