博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Dynamics 365中的批量删除作业执行频率可以高于每天一次吗?
阅读量:5258 次
发布时间:2019-06-14

本文共 6700 字,大约阅读时间需要 22 分钟。

微软动态CRM专家罗勇 ,回复317或者20190314可方便获取本文,同时可以在第一间得到我发布的最新博文信息,follow me!我的网站是 www.luoyong.me 。

我先来做一个例子,登录Dynamics 365 Customer Engagement以后导航到 【设置】> 【数据管理】> 【批量删除记录】,点击【新建】按钮新建一个,如下,

 

 

 可以看到我能选择的改批量删除任务执行的最高频率就是每天执行一次,如果我要更加频繁的执行频率呢?可以更改吗?根据官方文档  我来改改看。

待第一次运行完毕后,我用T-SQL看下这个作业,有两条记录,一条是父记录,也就是我定义的批量删除记录,另一个是运行一次后产生的记录,主要区别在于RecurrenceStartTime和RecurrencePattern字段有值,前面字段定义了什么时候开始,后面字段定义了执行频率。

 

如何更改呢,很简单啊,就改RecurrencePattern字段和recurrencestarttime字段的值,为了方便大家执行,我这里用JavaScript调用Web API来查询和更改。

var clientURL = Xrm.Page.context.getClientUrl();        var jobName = '删除一个月之前创建的已成功/失败/取消的系统作业';        var req = new XMLHttpRequest();        var jobId = "";        req.open("GET", encodeURI(clientURL + "/api/data/v9.0/asyncoperations?$select=asyncoperationid&$orderby=createdon asc&$filter=name eq '" + jobName + "' and recurrencepattern ne null&$top=1"), true);        req.setRequestHeader("Accept", "application/json");        req.setRequestHeader("Content-Type", "application/json; charset=utf-8");        req.setRequestHeader("OData-MaxVersion", "4.0");        req.setRequestHeader("OData-Version", "4.0");        req.onreadystatechange = function () {            if (this.readyState == 4) {                req.onreadystatechange = null;                if (this.status == 200) {                    var responseJSON = JSON.parse(this.responseText);                    if (responseJSON.value != null && responseJSON.value.length == 1) {                        jobId = responseJSON.value[0].asyncoperationid;                        req = new XMLHttpRequest();                        req.open("PATCH", encodeURI(clientURL + "/api/data/v9.0/asyncoperations(" + jobId + ")"), true);                        req.setRequestHeader("Accept", "application/json");                        req.setRequestHeader("Content-Type", "application/json; charset=utf-8");                        req.setRequestHeader("OData-MaxVersion", "4.0");                        req.setRequestHeader("OData-Version", "4.0");                        req.onreadystatechange = function () {                            if (this.readyState == 4 /* complete */) {                                req.onreadystatechange = null;                                if (this.status == 204) {                                    Xrm.Utility.alertDialog("Operation done successfully!");                                }                                else {                                    var error = JSON.parse(this.response).error;                                    Xrm.Utility.alertDialog("Error." + error.message);                                }                            }                        };                        var requestMsg = {};                        requestMsg["recurrencepattern"] = "FREQ=HOURLY;INTERVAL=12;";                        requestMsg["recurrencestarttime"] = new Date();                        req.send(JSON.stringify(requestMsg));                    }                    else {                        Xrm.Utility.alertDialog("Cann't find the recurrent job " + jobName);                    }                }                else {                    var error = JSON.parse(this.responseText).error;                    Xrm.Utility.alertDialog("Error." + error.message);                }            }        };        req.send();

可以执行,但是报错Bulk Delete and Duplicate Detection recurrence must be specified as daily.,报错信息如下:

{     "error":{        "code":"0x8004d2a0",      "message":"Bulk Delete and Duplicate Detection recurrence must be specified as daily.",      "innererror":{           "message":"Bulk Delete and Duplicate Detection recurrence must be specified as daily.",         "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, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType, Boolean checkAdminMode, ExecutionContext executionContext)\r\n   at Microsoft.Crm.Extensibility.OData.CrmODataExecutionContext.Upsert(Entity entity)\r\n   at Microsoft.Crm.Extensibility.OData.CrmODataExecutionContext.Update(Entity entity, UpdateOption updateOption)\r\n   at Microsoft.Crm.Extensibility.OData.CrmODataServiceDataProvider.UpdateEdmEntity(CrmODataExecutionContext context, String edmEntityName, String entityKeyValue, EdmEntityObject entityObject)\r\n   at Microsoft.Crm.Extensibility.OData.EntityController.PatchEntityImplementation(String& entityName, String key, EdmEntityObject entityDelta)\r\n   at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute[TResult](ILogger logger, EventId eventId, ActivityType activityType, Func`1 func)\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.
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.
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.
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.
d__1.MoveNext()" } }}

 

当然,不能改到更密集的话,也没有必要用代码来改动,界面上可以操作。导航到【设置】> 【数据管理】> 【批量删除记录】,选择【定期的批量删除系统作业】这个视图,打开要更改的批量删除作业

 

点击【操作】 > 【修改定期项】

 

做合适的设置就可以了,当然,如果想取消这个,将其设置为 【从不】就可以了。

 

转载于:https://www.cnblogs.com/luoyong0201/p/Dynamics_Async_Operation_Bulk_Delete_Alter_Frequency.html

你可能感兴趣的文章
类的继承 设计模式
查看>>
Delphi匿名方法(一):初识
查看>>
工作流系统概述
查看>>
swift学习笔记4——扩展、协议
查看>>
Android NDK(C++) 双进程守护
查看>>
提高速度 history 的利用
查看>>
●POJ 1509 Glass Beads
查看>>
docker 基本命令
查看>>
LTrim、RTrim 和 Trim 函数
查看>>
宝塔Linux面板新手安装教程【转】
查看>>
HBH_IOS开发之界面转换
查看>>
一文搞懂Raft算法
查看>>
sql中检查时间是否重叠
查看>>
【MVC】ASP.Net MVC 4项目升级MVC 5的方法
查看>>
做人、做事,做架构师——架构师能力模型解析
查看>>
Dinic二分图匹配 || Luogu P3386
查看>>
DNS正向解析
查看>>
通过 BitNami 轻松安装 Redmine
查看>>
zzulioj--1778-- 和尚特烦恼4——有多少战斗力(gcd)
查看>>
.net 操作Oracle 海量数据
查看>>