0

我尝试使用 mobileNumber、telephone1 等字段搜索联系人。但是当我尝试使用以下代码查看对象的所有属性时,

for (var property in primaryContact) {
                        document.write(property);
                    }

我得到输出,

__metadata , FullName , ContactId ,

我使用了动态 CRM SDK 中的 SDK.Rest。

如何使用任何特定属性在动态 CRM 中搜索联系人?

完整的代码,

//adding new_SDK.REST
var script = document.createElement('script');
script.src = 'new_SDK.REST';
script.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(script);

//adding new_json2
var script = document.createElement('script');
script.src = 'new_json2';
script.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(script);

function getFirstContactToBePrimaryContact() {

    SDK.REST.retrieveMultipleRecords(
        "Contact",
        "$select=ContactId,FullName&$top=4",
        function (results) {
            var firstResult = results[0];
            if (firstResult != null) {
                primaryContact = results[0];

                for (var property in primaryContact) {
                    document.write(property);
                }
                document.write(primaryContact.FullName + ' ' + primaryContact.address1_telephone1);

            }
            else {
                writeMessage("No Contact records are available to set as the primary contact for the account.");
            }
        },
        errorHandler,
        function () {
            //OnComplete handler
        }
      );
}


function errorHandler(error) {
    writeMessage(error.message);
}
4

1 回答 1

0

您必须在查询的选择部分设置要从 CRM 检索的所有参数。在此链接上,您有一个示例。

所以它会像:

SDK.REST.retrieveMultipleRecords(
    "Contact",
    "$select=ContactId,FullName,mobilephone&$top=4",

对于基于特定参数的搜索,请使用过滤器表达式-链接。例如:

/ContactSet?$filter=mobilephone eq '123456'

希望这可以帮助。

于 2014-10-16T03:35:49.123 回答