Dynamic CRM常用代码记录
Dynamic CRM 查询实体记录 被共享给了 哪个用户
--客户表名"new_customer" SELECT u.FullName AS 被共享人,a.new_name AS 客户名称,sup.SystemUserid AS 共享人ID,POA.ObjectId AS 共享记录ID FROM PrincipalObjectAccess POA inner join SystemUserPrincipals sup on POA.PrincipalId = sup.PrincipalId inner join SystemUserBase u on sup.SystemUserId=u.SystemUserId inner join dbo.new_customer a on a.new_customerId=POA.ObjectId WHERE POA.ObjectId IN (SELECT new_customerId FROM dbo.new_customer)
--查询实体信息,实体名称:account select * from MetadataSchema.Entity where name= 'account'
查询窗体信息,ObjectTypeCode: 实体的code select * from systemform where ObjectTypeCode = 1
查询视图信息: --查询视图信息,ReturnedTypeCode:实体的code select * from SavedQuerybase where ReturnedTypeCode = 1
查询字段信息: --查询字段信息 with attr as( select * from MetadataSchema.Attribute as a where a.EntityId in (select entityid from MetadataSchema.Entity where name = 'new_member') and a.IsCustomField = 1 ) select a.attributeid,a.Name,label.Label,ty.Description, (select top 1 name from MetadataSchema.Entity where EntityId in ( select ship.ReferencedEntityId from MetadataSchema.Relationship as ship where ship.ReferencingAttributeId = a.AttributeId)) as 'lookName' from attr as a inner join MetadataSchema.LocalizedLabel as label on a.attributeid = label.objectid inner join MetadataSchema.AttributeTypes as ty on a.AttributeTypeId = ty.AttributeTypeId where label.objectcolumnname = 'DisplayName' and a.validforcreateapi = 1
查询关系信息: select * from MetadataSchema.Relationship where ReferencingEntityId in (select top 1 entityid from MetadataSchema.Entity where name = 'new_store')
实体ID查询方法: SELECT ObjectTypeCode from Entity where name='实体名称' 调用函数方法: select getpicklist('字段名称',字段值,实体ID)
--@AttributeName 字段名称 --@AttributeValue 字段值 --@ObjectTypeCode 实体ID create function GetPickList( @AttributeName varchar(100), @AttributeValue int, @ObjectTypeCode int ) returns varchar(100) as begin declare @value varchar(100) SELECT @value=Value FROM StringMap where AttributeName=@AttributeName AND AttributeValue=@AttributeValue and ObjectTypeCode=@ObjectTypeCode return @value end
查询 picklist的方法:
select a.AttributeValue ,a.Value from StringMap a where a.ObjectTypeCode=1 and a.AttributeName='new_acc_type' and Attributevalue=100000000
Microsoft Dynamics CRM 解决数据大于5000时,页面上只能导出5000+数据。
页面显示: update [MSCRM_CONFIG].[dbo].[DeploymentProperties] set IntColumn=10000 --调整成10000+ 页面导出: 一、在CRM2011中如果想要导出超过10000记录数据,做法如下:针对CRM2011导出Excel 时,默认只能导出10000的限制在CRM2011产品中的MSCRM 对应的组织数据库中,找到名为organizationbase的表, 修改列名为maxrecordsforexporttoexcel的值即可。此处可不要随便将值设置为-1 。 二、在 CRM2011中如果想要显示5000+之后的具体记录数,做法如下: 针对全局的显示记录数最大值设置在CRM2011产品中的后台MSCRM_Config数据库中表名为DeploymentProperties的系统级的参数设定表,找到ColumnName为 PagingLimt的记录,将IntColumn更改为最大的记录限制数如50000,如果更改为无限制(有多少记录显示多数记录数)则可设置为-1,修改完成后重启IIS (iisreset)生效针对用户每页显示记录条数的设置 在MSCRM中可通过个人选项设置单页的最大显示记录条数,但最大值为250, 多么好的一个数值,但往往很多客户都想要超越这一值, 通过修改后台表参数也可以达到修改的目的。此 表在MSCRM对应的组织数据库中,如组织名为Sky,则此表在sky_mscrm下,表名为UserSettings ,修改列名为PagingLimt的值即可,此处可不要随便将值设置为-1 。 三,代码只能查出5000+数据方法 update OrganizationBase set MaxRecordsForExportToExcel = 99999999
CRM 数据密钥 忘记 解决方案
UPDATE EmailServerProfile SET IncomingPassword=null UPDATE EmailServerProfile SET OutgoingPassword=null UPDATE Mailbox SET Password=null UPDATE Queue SET EmailPassword=null UPDATE UserSettings SET EmailPassword=null
netsh http show urlacl
netsh http del urlacl https://+:443/adfs/
netsh http del urlacl https://+:443/FederationMetadata/2007-06/
配置ifd命令:
Add-PSSnapin Microsoft.Crm.PowerShell $ifd = Get-CrmSetting -SettingType "IfdSettings"
$ifd.Enabled = 1
$ifd.DiscoveryWebServiceRootDomain = "devurl" //auth.servername:446
$ifd.ExternalDomain ="https://authurl" // https://auth.server:446
$ifd.OrganizationWebServiceRootDomain= "domain+port" // domain+port
$ifd.WebApplicationRootDomain ="zenner.com.cn:446" //serverurl
Set-CrmSetting $ifd iisreset
Set-ADFSRelyingPartyTrust –TargetName "server" –TokenLifetime 500 //单位 分钟 server: anth url
Set-ADFSRelyingPartyTrust –TargetName "CRM Claims Relying Party" –TokenLifetime 500
ifd XRMTool 工具链接字符串
AuthType=IFD;Url=https://servername:port/organizationname;
HomeRealmUri=https://servername:port/adfs/services/trust/mex/;
Username=domin\username; Password=password
ADFS 证书 验证 设置
Set-AdfsProperties -AutoCertificateRollover $true
Set-AdfsRelyingPartyTrust -targetname "IFD Access" -signingcertificaterevocationcheck none