本人微信公众号:微软动态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. ndk编译faac生成库

    1.编译脚本如下: NDK=/opt/android-ndk-r9d TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/linu ...

  2. Kubernetes(k8s)1.12.2集群搭建

    本博客搭建k8s集群1.12.2版本 1. 准备2台以上最低2核4G的服务器 2. 关闭机器的防火墙 12 systemctl disable firewalldsystemctl stop fire ...

  3. JAVA基础—线程池

    推荐文章java多线程基础 线程池概述 为什么要使用线程池 1.服务器创建和销毁工作线程的开销很大 2.如果频繁的创建和销毁线程会导致频繁的切换线程,因为一个线程被销毁后,必然要把CPU转让给另一个已 ...

  4. Win10U盘启动盘制作及Win10系统安装

    准备工具: 1:一个8GU盘 2:下载MediaCreationTool1803.exe程序 及参考文档. 启动盘制作步骤: 1:运行 2:按照截图步骤依次...... 3:制作完成后插拔一下U盘在看 ...

  5. [Swift]LeetCode255.验证二叉搜索树的先序序列 $ Verify Preorder Sequence in Binary Search Tree

    Given an array of numbers, verify whether it is the correct preorder traversal sequence of a binary ...

  6. [Swift]LeetCode819. 最常见的单词 | Most Common Word

    Given a paragraph and a list of banned words, return the most frequent word that is not in the list ...

  7. [Swift]LeetCode865. 具有所有最深结点的最小子树 | Smallest Subtree with all the Deepest Nodes

    Given a binary tree rooted at root, the depth of each node is the shortest distance to the root. A n ...

  8. [Swift]LeetCode886. 可能的二分法 | Possible Bipartition

    Given a set of N people (numbered 1, 2, ..., N), we would like to split everyone into two groups of  ...

  9. so库链接和运行时选择哪个路径下的库?

    总结今天遇到的一个so库链接.运行问题. 这几天修改了xapian的源码,重新编译so库,再重新编译之前的demo程序,跑起来后却发现执行的函数并非我修改过的,使用的还是老版本.折腾了一会儿,发现是因 ...

  10. PHP-mysqli 出错回显

    面向对象风格 <?php $conn = new mysqli("localhost", "username", "password" ...