本人微信公众号:微软动态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. Shadow Copying导致ASP.NET应用启动很慢的解决办法

    What's Shadow Copying? 我们安装一个应用程序并启动后,我们是无法更新应用程序安装目录中程序集文件的.如果强制替换会提示文件正在使用,如下图所示. 那你可能会问,为什么会无法更新呢 ...

  2. vue项目实践-前后端分离关于权限的思路

    前后端分离后权限的思路 最近看到许多关于权限的思路,但好像都是使用动态加载路由的方式,现在也分享下我在项目中使用的解决方案. 前后端分离关于权限的处理每个人都不一样,根据项目选择制定合适的方案就好 我 ...

  3. MySQL InnoDB 备份与恢复七种方式

    有几种方式: 1 mysqldump, 这种方式不仅适用于InnoDB,还适用于其它类型的存储引擎,如MyISAM.备份的时候将数据库备份成SQL(包含drop,create,insert等语句),恢 ...

  4. [Swift]LeetCode736. Lisp 语法解析 | Parse Lisp Expression

    You are given a string expressionrepresenting a Lisp-like expression to return the integer value of. ...

  5. [Swift]LeetCode828. 独特字符串 | Unique Letter String

    A character is unique in string S if it occurs exactly once in it. For example, in string S = " ...

  6. git入门笔记汇总——(廖雪峰博客git入门)

    本文内容是对廖雪峰老师Git教程做的笔记,外加一些自己的学习心得,还抱着学以致用的心态来实践一番 如有显示错误 请移步本人github:git教程小结 Git学习笔记 Git简介 安装Git 创建版本 ...

  7. [bzoj4771] 七彩树

    题意 给定一棵n个点,每个点带颜色的有根树.点的编号和颜色编号都在1到n,根的编号为1.m次询问,求x子树中与x距离边数不超过k的点中,颜色的种类数目.每个测试点有多组数据. 分析 不妨设1的父亲为0 ...

  8. bootstrap4的出现(或这篇文章可以叫做bs4与bs3的区别)

    前言:在bootstrap4出现之后修改了bootstrap3的不方便之处,让使用框架的前端开发者更加便捷..(bootstrap下文中简称为bs) 一.栅格系统 相对于原来的bs3,bs4具有了范围 ...

  9. 仓储模式Repository的选择与设计

    首次接触仓储的概念来自Eric Evans 的经典著作<领域驱动设计-软件核心复杂性应对之道>,但书中没有具体实现.如何实现仓储模式,在我这几年的使用过程中也积累了一些具体的实施经验.根据 ...

  10. C#版 - Leetcode 215. Kth Largest Element in an Array-题解

    版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. C#版 - L ...