简体   繁体   English

如何使用javascript获取实体的属性值?

[英]How to get the value of an attribute of a entity using javascript?

For example, if I have a contact lookup field, and each contact record has many attributes, such as id, name, company, etc. How do I get the value of, say, the company attribute? 例如,如果我有一个联系人查找字段,并且每个联系人记录都具有许多属性,例如id,姓名,公司等。我如何获得company属性的值?

Thanks in advance. 提前致谢。

Update: 更新:

I can now get the value id ({55FCBC5D-xxxx-xxxx-xxxx-005056A63DAF}) using Retrieve method provided by crm service, but i also need the text name of the value. 现在,我可以使用crm服务提供的Retrieve方法获取值id({55FCBC5D-xxxx-xxxx-xxxx-005056A63DAF}),但我还需要该值的文本名称。 How can I do that? 我怎样才能做到这一点?

A contact lookup field is of type EntityReference . 联系人查找字段的类型为EntityReference As such, it only contains the bare essentials needed to uniquely identify the record: its Id (in this case, "ContactId"), LogicalName (the name of the entity to which the reference belongs - in this case, "contact"), and, if you're lucky, Name (in this case, likely FullName ). 因此,它仅包含唯一标识记录所需的基本要素:其Id (在这种情况下为“ ContactId”), LogicalName (引用所属的实体的名称-在这种情况下为“ contact”),并且,如果幸运的话,还可以使用Name (在这种情况下,可能是FullName )。

So to get any additional information about the contact, you're going to have to ask the Contact entity for that information via a query using the EntityReference . 因此,要获取有关该联系人的任何其他信息,您将不得不通过使用EntityReference的查询向Contact实体询问该信息。 Id . Id There's lots of examples of this @StackOverflow and around the web - see CRM 2011: Getting entity with Javascript for a popular way here. @StackOverflow和网络上有很多示例,请参见CRM 2011:使用Java脚本获取实体,以了解一种流行的方式。

There is also a CodePlex project called " CRM 2011 Lookup Preview " that seems to cleverly preview this sort of information on forms, but this may/may not be what you're looking for. 还有一个名为“ CRM 2011查找预览 ”的CodePlex项目,该项目似乎可以巧妙地预览表单上的此类信息,但这可能不是您想要的。

通过使用两个查询解决了问题(crmService提供的Retrieve方法)。

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

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