【问题标题】:Dynamics 365 RetrieveAttributeChangeHistory OData function for audit entity审核实体的 Dynamics 365 RetrieveAttributeChangeHistory OData 函数
【发布时间】:2019-09-03 16:20:08
【问题描述】:

上下文

尝试来自 Dynamics 365 audit 实体的 RetrieveAttributeChangeHistory。我需要一些帮助来形成该实体上 OData 函数的正确语法。由于该功能未绑定,因此我遇到了一些麻烦并遇到了以下错误。一旦我解决了这个问题,我就可以在我的 Java 程序中实现这个调用。

https://myorg.api.crm.dynamics.com/api/data/v9.0/RetrieveAttributeChangeHistory

错误

{
    "error": {
        "code": "0x80040203",
        "message": "Required field 'Target' is missing",
        "innererror": {
            "message": "Required field 'Target' is missing",
            "type": "System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]",
            "stacktrace": "   at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.Execute(OrganizationRequest request, InvocationContext invocationContext, CallerOriginToken callerOriginToken, WebServiceType serviceType, Boolean checkAdminMode, ExecutionContext executionContext, Dictionary`2 optionalParameters)\r\n   at Microsoft.Crm.Extensibility.OData.CrmODataExecutionContext.Execute(OrganizationRequest request, ExecutionContext executionContext)\r\n   at Microsoft.Crm.Extensibility.OData.CrmODataServiceDataProvider.ExecuteOperation(CrmODataExecutionContext context, EdmOperation edmOperation, Dictionary`2 parameters, Dictionary`2 boundParameters)\r\n   at Microsoft.Crm.Extensibility.OData.ActionController.ProcessOperationRequest(String operationName, Dictionary`2 operationParameters, EntityReference entityReference, String boundEntityName, String boundEntityType)\r\n   at Microsoft.Crm.Extensibility.OData.ActionController.<>c__DisplayClass12_0.<GetUnboundFunction>b__0()\r\n   at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute[TResult](ILogger logger, EventId eventId, ActivityType activityType, Func`1 func, IEnumerable`1 additionalCustomProperties)\r\n   at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute[TResult](ILogger logger, XrmTelemetryActivityType activityType, Func`1 func)\r\n   at lambda_method(Closure , Object , Object[] )\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"
        }
    }
}

【问题讨论】:

    标签: java rest dynamics-crm odata microsoft-dynamics


    【解决方案1】:

    我需要为我的 OData 函数提供正确的参数。有一个Compose Query functions example 使用LastXHours Function 来展示PropertyNamePropertyValue 需要如何通过URL 传递到函数括号中。

    GET [Organization URI]/api/data/v9.0/accounts?$select=name,accountnumber&$filter=Microsoft.Dynamics.CRM.LastXHours(PropertyName=@p1,PropertyValue=@p2)&@p1='modifiedon'&@p2=12
    

    RetrieveAttributeChangeHistory 需要以下参数才能正确调用。

    • 目标
    • 属性逻辑名称
    • 分页信息

    【讨论】:

      【解决方案2】:

      感谢格雷格!

      只是想为那些寻找RetrieveAttributeChangeHistory 函数的 GET 请求示例的人添加:

      GET [Organization URI]/api/data/v9.0/RetrieveAttributeChangeHistory(Target=@p1,AttributeLogicalName=@p2)?@p1={'@odata.id':'accounts(E7918C3A-B869-E811-8141-480FC8F421A1)'}&@p2='name'
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-03-07
        • 2021-06-07
        • 1970-01-01
        • 2019-04-17
        • 1970-01-01
        • 1970-01-01
        • 2019-02-17
        • 1970-01-01
        相关资源
        最近更新 更多