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

使用Microsoft Dynamics 365有时候会碰到类似如下的错误提示:Microsoft Dynamics 365 has encounted an error.

很多时候为了避免这个提示干扰用户操作,系统管理员会在安装后设置不弹出这个提示框。在【设置】>【管理】> 【隐私首选项】做如下设置即可。

  • 选中【代表用户指定 Web 应用程序错误通知首选项】
  • 选中【从不向 Microsoft 发送错误报告】

当然用户个人也是可以自己设置的,通过【选项】 > 【隐私】,选中【从不向 Microsoft 发送有关 Microsoft Dynamics 365 的错误报告】并确认保存。

但是有的Dynamics 365版本如下部分不会出现,怎么做个全局设置呢?

办法也是有的,可以使用消息来更新Organiaztion实体的 reportscripterrors 属性值,通过MetadataBrowser可以知道该属性是选项集,有如下四个选项:

  • 0 代表 没有用于向 Microsoft 发送有关 Microsoft Dynamics 365 错误报告的首选项
  • 1 代表 征得本人同意后向 Microsoft 发送错误报告
  • 2 代表 自动向 Microsoft 发送错误报告,不必征得本人同意
  • 3 代表 从不向 Microsoft 发送有关 Microsoft Dynamics 365 的错误报告

我是用如下的代码来更新为 0 看看:

using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Sdk.Query;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.ServiceModel.Description;
using System.Text;
using System.Threading.Tasks; namespace UpdateOrgAttribute
{
class Program
{
static void Main(string[] args)
{
IServiceManagement<IOrganizationService> orgServiceMgr = ServiceConfigurationFactory.CreateManagement<IOrganizationService>(new Uri(ConfigurationManager.AppSettings["orgUrl"]));
AuthenticationCredentials orgAuCredentials = new AuthenticationCredentials();
orgAuCredentials.ClientCredentials.UserName.UserName = ConfigurationManager.AppSettings["userName"];
orgAuCredentials.ClientCredentials.UserName.Password = ConfigurationManager.AppSettings["passWord"];
using (OrganizationServiceProxy orgSvc = GetProxy<IOrganizationService, OrganizationServiceProxy>(orgServiceMgr, orgAuCredentials))
{
WhoAmIRequest whoReq = new WhoAmIRequest();
WhoAmIResponse whoRep = orgSvc.Execute(whoReq) as WhoAmIResponse;
var userEntity = orgSvc.Retrieve("systemuser", whoRep.UserId, new ColumnSet("fullname"));
Console.WriteLine(string.Format("登录组织{0}成功,欢迎{1},继续操作请输入y!", ConfigurationManager.AppSettings["orgUrl"], userEntity.GetAttributeValue<string>("fullname")));
var input = Console.ReadLine().ToString().ToUpper();
if (input == "Y")
{
QueryExpression pagequery = new QueryExpression("organization");
pagequery.ColumnSet.AllColumns = true;
Console.WriteLine("组织的各项属性及其值如下:");
foreach (var attr in orgSvc.RetrieveMultiple(pagequery).Entities[].Attributes.Where(t => t.Key != "sitemapxml" && t.Key != "referencesitemapxml").OrderBy(t => t.Key))
{
Console.WriteLine(string.Format("{0} : {1}", attr.Key, attr.Value.GetType() == typeof(Microsoft.Xrm.Sdk.OptionSetValue) ? ((OptionSetValue)attr.Value).Value : attr.Value));
Console.WriteLine("==============================================");
}
Console.WriteLine("请为【reportscripterrors】输入你要设置的值:");
Console.WriteLine("0 代表 没有用于向 Microsoft 发送有关 Microsoft Dynamics 365 错误报告的首选项");
Console.WriteLine("1 代表 征得本人同意后向 Microsoft 发送错误报告");
Console.WriteLine("2 代表 自动向 Microsoft 发送错误报告,不必征得本人同意");
Console.WriteLine("3 代表 从不向 Microsoft 发送有关 Microsoft Dynamics 365 的错误报告");
input = Console.ReadLine().ToString().Trim();
var orgEntity = new Entity("organization", orgSvc.RetrieveMultiple(pagequery).Entities[].Id);
orgEntity["reportscripterrors"] = new OptionSetValue(Convert.ToInt32(input));
orgSvc.Update(orgEntity);
Console.WriteLine("更新成功!");
}
}
Console.WriteLine("程序执行完毕!");
Console.ReadKey();
} private static TProxy GetProxy<TService, TProxy>(
IServiceManagement<TService> serviceManagement,
AuthenticationCredentials authCredentials)
where TService : class
where TProxy : ServiceProxy<TService>
{
Type classType = typeof(TProxy); if (serviceManagement.AuthenticationType !=
AuthenticationProviderType.ActiveDirectory)
{
AuthenticationCredentials tokenCredentials =
serviceManagement.Authenticate(authCredentials);
return (TProxy)classType
.GetConstructor(new Type[] { typeof(IServiceManagement<TService>), typeof(SecurityTokenResponse) })
.Invoke(new object[] { serviceManagement, tokenCredentials.SecurityTokenResponse });
}
return (TProxy)classType
.GetConstructor(new Type[] { typeof(IServiceManagement<TService>), typeof(ClientCredentials) })
.Invoke(new object[] { serviceManagement, authCredentials.ClientCredentials });
}
}
}

下面是执行截图:

这样更新后,界面上会显示不出来,对CRM的应用程序池执行一下【回收...】就可以看到效果了。

Dynamics 365设置错误通知首选项的方法的更多相关文章

  1. NX二次开发-UFUN工程图表格注释设置单元格首选项UF_TABNOT_set_cell_prefs

    NX9+VS2012 #include <uf.h> #include <uf_tabnot.h> #include <NXOpen/Part.hxx> #incl ...

  2. 如何解决Dynamics 365的错误:用户身份验证无效,MSIS0006

    关注本人微信和易信公众号: 微软动态CRM专家罗勇 ,回复246或者20170312可方便获取本文,同时可以在第一间得到我发布的最新的博文信息,follow me!我的网站是 www.luoyong. ...

  3. Windows 8 动手实验系列教程 实验6:设置和首选项

    动手实验 实验6:设置和首选项 2012年9月 简介 实验3介绍了合约并演示了应用程序如何轻松地与共享和搜索合约实现集成.合约同样包含设置超级按钮,它对活动的Windows应用商店应用的设置进行修改. ...

  4. Google AdWords 广告排名首选项

    排名首选项目标:了解 AdWords 广告客户可怎样为其广告设置排名首选项. 排名首选项简介 通过排名首选项,用户可以告诉 Google 他们希望其广告在给定网页上的所有 AdWords 广告中所处的 ...

  5. NX二次开发-UFUN工程图表格注释检索默认单元格首选项UF_TABNOT_ask_default_cell_prefs

    NX9+VS2012 #include <uf.h> #include <uf_tabnot.h> #include <NXOpen/Part.hxx> #incl ...

  6. PHP 错误与异常 笔记与总结(3)PHP 配置文件(php.ini)中与错误相关的选项 与 设置错误级别

    [PHP 配置文件中与错误相关的选项 ] 选项 描述 error_reporting 设置错误报告的级别 display_errors 是否显示错误 log_errors 设置是否将错误信息记录到日志 ...

  7. Dynamics 365出现数据加密错误怎么办?

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

  8. Dynamics 365客户端编程示例:获取当前用户的信息,表单级通知/提示,表单OnLoad事件执行代码

    我是微软Dynamics 365 & Power Platform方面的工程师罗勇,也是2015年7月到2018年6月连续三年Dynamics CRM/Business Solutions方面 ...

  9. 使用Dynamics 365 CE Web API查询数据加点料及选项集字段常用查询

    微软动态CRM专家罗勇 ,回复336或者20190516可方便获取本文,同时可以在第一间得到我发布的最新博文信息,follow me. 紧接上文:配置Postman通过OAuth 2 implicit ...

随机推荐

  1. HTML5调用手机摄像机、相册功能 <input>方法

    最近用MUI框架做webapp项目,在有PLUS环境的基础上能直接调用手机底层的API来使用拍照或从相册选择上传功能! 在查资料的时候,想起了另一种用input调用摄像和相册功能的方法,之前没有深入了 ...

  2. The algorithm learning of sort which include Bubblesort,Insertsort,Quicksort and Mergesort.

    Notice : these algorithms achieved by Java. So,let's going to it. firstly, what is Bubblesort? why w ...

  3. [Swift]LeetCode633. 平方数之和 | Sum of Square Numbers

    Given a non-negative integer c, your task is to decide whether there're two integers a and b such th ...

  4. [Swift]LeetCode815. 公交路线 | Bus Routes

    We have a list of bus routes. Each routes[i]is a bus route that the i-th bus repeats forever. For ex ...

  5. springmvc 请求参数解析细节

    springmvc 的请求流程,相信大家已经很熟悉了,不熟悉的同学可以参考下资料! 有了整体流程的概念,是否对其中的实现细节就很清楚呢?我觉得不一定,比如:单是参数解析这块,就是个大学问呢? 首先,我 ...

  6. python之PIL库(Image模块)

    PIL(Python Image Library)是python的第三方图像处理库,PIL的功能非常的强大,几乎被认定是Python的官方图像处理库了. 由于PIL仅支持到python2.7于是一群志 ...

  7. firewall防火墙

    firewall防火墙 1 防火墙简介 在基于RHEL7的服务器,提供了一个firewall的动态管理的防火墙,其支持IPv4和IPv6,还支持以太网桥,并有分离运行时间和永久性配置选择.它还具备一个 ...

  8. PHPExcel使用笔记

    PHPExcel使用笔记 - 常见操作总结 最近做项目时,PHPExcel插件用得比较频繁,将其常见的操作总结一下- $objPHPExcel->getDefaultStyle()->ge ...

  9. JS判断客户端是否是iOS或者Android手机移动端(转载)

    前言: 上午有一个移动端的项目负责人问我,在ios系统上样式出现问题,因为内核原因,我改来改去,在ios弄好了,但在安卓有问题了,突然想到了一种办法,既然ios是一种机型,安卓是一种机型,可以检测用户 ...

  10. PE知识复习之PE的RVA与FOA的转换

    PE知识复习之PE的RVA与FOA的转换 一丶简介PE的两种状态 首先我们知道PE有两种状态.一种是内存展开.一种是在文件中的状态.那么此时我们有一个需求. 我们想改变一个全局变量的初始值.此时应该怎 ...