Dynamics 365设置错误通知首选项的方法
本人微信公众号:微软动态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设置错误通知首选项的方法的更多相关文章
- NX二次开发-UFUN工程图表格注释设置单元格首选项UF_TABNOT_set_cell_prefs
NX9+VS2012 #include <uf.h> #include <uf_tabnot.h> #include <NXOpen/Part.hxx> #incl ...
- 如何解决Dynamics 365的错误:用户身份验证无效,MSIS0006
关注本人微信和易信公众号: 微软动态CRM专家罗勇 ,回复246或者20170312可方便获取本文,同时可以在第一间得到我发布的最新的博文信息,follow me!我的网站是 www.luoyong. ...
- Windows 8 动手实验系列教程 实验6:设置和首选项
动手实验 实验6:设置和首选项 2012年9月 简介 实验3介绍了合约并演示了应用程序如何轻松地与共享和搜索合约实现集成.合约同样包含设置超级按钮,它对活动的Windows应用商店应用的设置进行修改. ...
- Google AdWords 广告排名首选项
排名首选项目标:了解 AdWords 广告客户可怎样为其广告设置排名首选项. 排名首选项简介 通过排名首选项,用户可以告诉 Google 他们希望其广告在给定网页上的所有 AdWords 广告中所处的 ...
- NX二次开发-UFUN工程图表格注释检索默认单元格首选项UF_TABNOT_ask_default_cell_prefs
NX9+VS2012 #include <uf.h> #include <uf_tabnot.h> #include <NXOpen/Part.hxx> #incl ...
- PHP 错误与异常 笔记与总结(3)PHP 配置文件(php.ini)中与错误相关的选项 与 设置错误级别
[PHP 配置文件中与错误相关的选项 ] 选项 描述 error_reporting 设置错误报告的级别 display_errors 是否显示错误 log_errors 设置是否将错误信息记录到日志 ...
- Dynamics 365出现数据加密错误怎么办?
本人微信公众号:微软动态CRM专家罗勇 ,回复290或者20181227可方便获取本文,同时可以在第一间得到我发布的最新博文信息,follow me!我的网站是 www.luoyong.me . Dy ...
- Dynamics 365客户端编程示例:获取当前用户的信息,表单级通知/提示,表单OnLoad事件执行代码
我是微软Dynamics 365 & Power Platform方面的工程师罗勇,也是2015年7月到2018年6月连续三年Dynamics CRM/Business Solutions方面 ...
- 使用Dynamics 365 CE Web API查询数据加点料及选项集字段常用查询
微软动态CRM专家罗勇 ,回复336或者20190516可方便获取本文,同时可以在第一间得到我发布的最新博文信息,follow me. 紧接上文:配置Postman通过OAuth 2 implicit ...
随机推荐
- Raiden Charge
2017年10月22 周日 这是个元气满满 值得纪念的一天(不好意思走错片场了) 虽然有各种乱遭的客观元素 但我们队确确实实地打铁了 那些我们轻视的 野鸡(误)大学 都在我们前面 都说知耻而后勇 虽然 ...
- Pycharm画五角星
import turtle turtle.setup(600,400,0,0) turtle.bgcolor('red') turtle.color('yellow') turtle.fillcolo ...
- libguestfs手册(2):guestfish command
添加一个drive:guestfs_add_drive_opts add-drive filename [readonly:true|false] [format:..] [iface:..] [na ...
- Redis基础入门,Redis的优点也特点,Redis五种数据类型
Redis是一个开源,高级的键值存储和一个适用的解决方案,用于构建高性能,可扩展的Web应用程序. 1.Redis的主要特点 Redis有三个主要特点,使它优越于其它键值数据存储系统 - Redis将 ...
- Truncated incorrect DOUBLE value: 'd'的解决方法(jdbc)
今天写jdbc中dao的增删改查时遇到了一个问题,花费了好长时间,不过还好,有我峰哥出头,问题解决了,在这做个分享,对峰哥表达一下感激之情 网上搜索到的对“Truncated incorrect DO ...
- 【TOGAF】总体认知
TOGAF是什么 TOGAF(The Open Group Architecture Framework)是当前最为流行的企业架构框架理论之一,它为一个企业或组织对于企业架构的接受.创建.使用和维护提 ...
- 微信小程序day01-JSON配置
微信小程序 小程序代码构成 JSON配置WXML模板WXSS样式JS逻辑 1.JSON配置 小程序配置 app.json app.json: 是当前小程序的全局配置,包括了小程序的所有页面路径.界面表 ...
- Git使用基础介绍
git教程:一.git的简介: -git是分布式版本控制系统由Linus为Linux用C语言写的. -什么是集中式版本控制系统: 版本库是集中存放在中央服务器,干活的时候用自己的电 ...
- idea设置代码颜色主题(同Sublime Text 3的代码颜色一样)
1.下载主题的网址:http://color-themes.com,主题种类多,总有适合你的主题.在这个网址下载的主题是jar文件,直接导入,如下图file->import Setting,找 ...
- 1.Django安装与运行
Django基本配置 Python的WEB框架有Django.Tornado.Flask 等多种,Django相较与其他WEB框架其优势为:大而全,框架本身集成了ORM.模型绑定.模板引擎.缓存.Se ...