我想使用纯Javascript从MS Dynamics CRM Online 2015添加/检索数据

I want to add/retrieve data from MS Dynamics CRM Online 2015 using pure Javascript

本文关键字:2015 Online CRM 添加 数据 检索 Dynamics MS Javascript      更新时间:2023-09-26

我想通过CRM 2015中的javascript用加载中的另一个实体的一些数据更新一个实体。是否可以?

在CRM 2011中,我使用了以下代码:

var xml = '' +
            '<?xml version=''1.0'' encoding=''utf-8''?>' +
            '<soap:Envelope xmlns:soap=''http://schemas.xmlsoap.org/soap/envelope/'' xmlns:xsi=''http://www.w3.org/2001/XMLSchema-instance'' xmlns:xsd=''http://www.w3.org/2001/XMLSchema''>' +
            ' <soap:Header>' +
            ' <CrmAuthenticationToken xmlns=''http://schemas.microsoft.com/crm/2007/WebServices''>' +
            ' <AuthenticationType xmlns=''http://schemas.microsoft.com/crm/2007/CoreTypes''>0</AuthenticationType>' +
            ' <OrganizationName xmlns=''http://schemas.microsoft.com/crm/2007/CoreTypes''>OrganizationName </OrganizationName>' +
            ' <CallerId xmlns=''http://schemas.microsoft.com/crm/2007/CoreTypes''>00000000-0000-0000-0000-000000000000</CallerId>' +
            ' </CrmAuthenticationToken>' +
            ' </soap:Header>' +
            ' <soap:Body>' +
            ' <RetrieveMultiple xmlns=''http://schemas.microsoft.com/crm/2007/WebServices''>' +
            ' <query xmlns:q1=''http://schemas.microsoft.com/crm/2006/Query'' xsi:type=''q1:QueryExpression''>' +
            ' <q1:EntityName></q1:EntityName>' +
            ' <q1:ColumnSet xsi:type=''q1:ColumnSet''>' +
            ' <q1:Attributes>' +
            ' <q1:Attribute></q1:Attribute>' +
            ' </q1:Attributes>' +
            ' </q1:ColumnSet>' +
            ' <q1:Distinct>false</q1:Distinct>' +
            ' <q1:Criteria>' +
            ' <q1:FilterOperator>And</q1:FilterOperator>' +
            ' <q1:Conditions>' +
            ' <q1:Condition>' +
            ' <q1:AttributeName>new_estadoid</q1:AttributeName>' +
            '<q1:Operator>Equal</q1:Operator>' +
            '<q1:Values>' +
            '<q1:Value xsi:type=''xsd:string''>' + "" + '</q1:Value>' +
            '</q1:Values>' +
            ' </q1:Condition>' +
            ' </q1:Conditions>' +
            ' </q1:Criteria>' +
            ' </query>' +
            ' </RetrieveMultiple>' +
            ' </soap:Body>' +
            '</soap:Envelope>' +
            '';

看看CRM SDK,它包括一个javascript文件SDK.REST.js,它将允许您通过一个简单的调用来执行RetrieveMultipleRecords。

建议您下载(Dynamics CRM SDK):

https://msdn.microsoft.com/en-us/library/hh547453.aspx

这个页面展示了如何使用SDK.REST.js从CRM:中检索记录

https://msdn.microsoft.com/en-us/library/gg985387.aspx

简而言之,您可以调用SDK.REST.removeeMultipleRecords()函数,并从JavaScript中获取所需的数据。

不确定,但您正在做的事情可能有点太复杂,无法完成此任务。您可以在没有javascript的情况下实现这一功能。我正在MS CRM 2013内部解决同样的问题,可以与您分享我所学到的,希望它也适用于您。

您可以构建工作流(流程:https://technet.microsoft.com/en-us/library/dn531067.aspx)在需要信息的实体上创建新记录之前被触发的系统上,添加源实体的动态值以在加载时显示在创建表单上。

您可以参考这篇文章来解释此解决方案的一些步骤:https://www.salentica.com/crm-2013-real-time-workflows/

*需要注意的是,这两个实体必须与系统中定义的关系相关。