EXEC sp_spaceused N'User.ContactInfo';
Search This Blog
Wednesday, March 6, 2019
SQL Query to Get Table Index fragmentation
Query:
SELECT * FROM sys.dm_db_index_physical_stats(dbid, table_objectid, NULL, NULL , 'LIMITED')
ORDER BY avg_fragmentation_in_percent DESC
SELECT * FROM sys.dm_db_index_physical_stats(dbid, table_objectid, NULL, NULL , 'LIMITED')
ORDER BY avg_fragmentation_in_percent DESC
SQL Query to Get Database ID and Table Object ID in Dynamics CRM
Get DB Id:
SELECT DB_ID(N'dbname') AS [Database ID];
Get Table Object ID:
Use dbname
SELECT name, object_id
FROM sys.tables
WHERE name = 'IncidentBase';
GO
SELECT DB_ID(N'dbname') AS [Database ID];
Get Table Object ID:
Use dbname
SELECT name, object_id
FROM sys.tables
WHERE name = 'IncidentBase';
GO
Friday, March 1, 2019
Get and Set Dynamics CRM Attribute Values in c#
Set OptionsetValue:
entity.Attributes.Add("attributename", new OptionSetValue(1));
Set Money Attribute:
Decimal creditlimit=0;
entity.Attributes.Add("attributename", new Money(creditlimit));
Set Lookup:
EntityReference _event = new EntityReference();
_event.Id = guid;
_event.LogicalName = "entityname";
_event.Name = name;
entity.Attributes["attributename"] = _event;
DateTime:
entity.Attributes.Add("attributename", Start_date);
entity.Attributes.Add("attributename", new OptionSetValue(1));
Set Money Attribute:
Decimal creditlimit=0;
entity.Attributes.Add("attributename", new Money(creditlimit));
Set Lookup:
EntityReference _event = new EntityReference();
_event.Id = guid;
_event.LogicalName = "entityname";
_event.Name = name;
entity.Attributes["attributename"] = _event;
DateTime:
entity.Attributes.Add("attributename", Start_date);
Get Alias Attribute Values in Dynamics CRM using c#
Single Line of Text:
String name = ((AliasedValue)entity.Attributes["name"]).Value.ToString();
OptionsetValue:
String optionsetvalue = ((AliasedValue)entity.Attributes["attributename"]).Value.ToString();
OptionsetText:
String optionsettext = entity.FormattedValues["attributename"].ToString();
Lookup:
String name = ((EntityReference)((AliasedValue)entity.Attributes["attributename"]).Value).Name;
String id= ((EntityReference)((AliasedValue)entity.Attributes["attributename"]).Value).Id.ToString();
Currency:
Fetchxml Query:
<entity name='account'>
<attribute name='name' />
<attribute name='accountid' />
<order attribute='name' descending='false' />
<filter type='and'>
<condition attribute='statecode' operator='eq' value='0' />
</filter>
<link-entity name='amountentity' from='amountentityid' to='amountentity' visible='false' link-type='outer' alias='amount_entity'>
<attribute name='totalamount' />
</link-entity>
</entity>
Decimal amount = ((Money)(((AliasedValue)student.Attributes["amount_entity.totalamount"])).Value).Value;
Whole Number:
int Totalnumber = Convert.ToInt16(((AliasedValue)entity.Attributes["totalcredithours"]).Value);
String name = ((AliasedValue)entity.Attributes["name"]).Value.ToString();
OptionsetValue:
String optionsetvalue = ((AliasedValue)entity.Attributes["attributename"]).Value.ToString();
OptionsetText:
String optionsettext = entity.FormattedValues["attributename"].ToString();
Lookup:
String name = ((EntityReference)((AliasedValue)entity.Attributes["attributename"]).Value).Name;
String id= ((EntityReference)((AliasedValue)entity.Attributes["attributename"]).Value).Id.ToString();
Currency:
Fetchxml Query:
<entity name='account'>
<attribute name='name' />
<attribute name='accountid' />
<order attribute='name' descending='false' />
<filter type='and'>
<condition attribute='statecode' operator='eq' value='0' />
</filter>
<link-entity name='amountentity' from='amountentityid' to='amountentity' visible='false' link-type='outer' alias='amount_entity'>
<attribute name='totalamount' />
</link-entity>
</entity>
Decimal amount = ((Money)(((AliasedValue)student.Attributes["amount_entity.totalamount"])).Value).Value;
Whole Number:
int Totalnumber = Convert.ToInt16(((AliasedValue)entity.Attributes["totalcredithours"]).Value);
Friday, October 26, 2018
Connect Dynamics CRM/365 V9 with Asp.net Application c#
using System.ServiceModel.Description;
using Microsoft.Xrm.Sdk;
IOrganizationService organizationService = null;
public void Connection()
{
try
{
ClientCredentials clientCredentials = new ClientCredentials();
clientCredentials.UserName.UserName = "username";
clientCredentials.UserName.Password = "password";
// For Dynamics 365 Customer Engagement V9.X, set Security Protocol as TLS12
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
// Get the URL from CRM, Navigate to Settings -> Customizations -> Developer Resources
// Copy and Paste Organization Service Endpoint Address URL
organizationService = (IOrganizationService)new OrganizationServiceProxy(new Uri("https://orgname.api.crm4.dynamics.com/XRMServices/2011/Organization.svc"),
null, clientCredentials, null);
if (organizationService != null)
{
Guid userid = ((WhoAmIResponse)organizationService.Execute(new WhoAmIRequest())).UserId;
if (userid != Guid.Empty)
{
Label1.Text = "Established Connection!!!";
}
}
else
{
Label1.Text = "Failed to Established Connection!!!";
}
}
catch (Exception ex)
{
Label1.Text = "Exception caught - " + ex.Message;
}
}
using Microsoft.Xrm.Sdk;
IOrganizationService organizationService = null;
public void Connection()
{
try
{
ClientCredentials clientCredentials = new ClientCredentials();
clientCredentials.UserName.UserName = "username";
clientCredentials.UserName.Password = "password";
// For Dynamics 365 Customer Engagement V9.X, set Security Protocol as TLS12
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
// Get the URL from CRM, Navigate to Settings -> Customizations -> Developer Resources
// Copy and Paste Organization Service Endpoint Address URL
organizationService = (IOrganizationService)new OrganizationServiceProxy(new Uri("https://orgname.api.crm4.dynamics.com/XRMServices/2011/Organization.svc"),
null, clientCredentials, null);
if (organizationService != null)
{
Guid userid = ((WhoAmIResponse)organizationService.Execute(new WhoAmIRequest())).UserId;
if (userid != Guid.Empty)
{
Label1.Text = "Established Connection!!!";
}
}
else
{
Label1.Text = "Failed to Established Connection!!!";
}
}
catch (Exception ex)
{
Label1.Text = "Exception caught - " + ex.Message;
}
}
Friday, September 21, 2018
Plugin Registration Tool For Dynamics 365 V9
Step 1: Create a folder in D Drive and name it as “Dynamics_365_Development_Tools“
Step 2: Click on Windows, search for Windows PowerShell and open it.
Step 3: Type the below command to change the directory.
Step 4: Copy & Paste the below PowerShell script in PowerShell Window to download tools from Nuget.
Step 5: Below Tools will be downloaded to D:\Dynamics_365_Development_Tools\Tools Folder.
Source Link: https://arunpotti.wordpress.com/tag/plugin-registration-tool-dynamics-365/
Step 2: Click on Windows, search for Windows PowerShell and open it.
Step 3: Type the below command to change the directory.
cd D:\Dynamics_365_Development_Toolsand press Enter.
Step 4: Copy & Paste the below PowerShell script in PowerShell Window to download tools from Nuget.
$sourceNugetExe = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" $targetNugetExe = ".\nuget.exe" Remove-Item .\Tools -Force -Recurse -ErrorAction Ignore Invoke-WebRequest $sourceNugetExe -OutFile $targetNugetExe Set-Alias nuget $targetNugetExe -Scope Global -Verbose ## ##Download Plugin Registration Tool ## ./nuget install Microsoft.CrmSdk.XrmTooling.PluginRegistrationTool -O .\Tools md .\Tools\PluginRegistration $prtFolder = Get-ChildItem ./Tools | Where-Object {$_.Name -match 'Microsoft.CrmSdk.XrmTooling.PluginRegistrationTool.'} move .\Tools\$prtFolder\tools\*.* .\Tools\PluginRegistration Remove-Item .\Tools\$prtFolder -Force -Recurse ## ##Download CoreTools ## ./nuget install Microsoft.CrmSdk.CoreTools -O .\Tools md .\Tools\CoreTools $coreToolsFolder = Get-ChildItem ./Tools | Where-Object {$_.Name -match 'Microsoft.CrmSdk.CoreTools.'} move .\Tools\$coreToolsFolder\content\bin\coretools\*.* .\Tools\CoreTools Remove-Item .\Tools\$coreToolsFolder -Force -Recurse ## ##Download Configuration Migration ## ./nuget install Microsoft.CrmSdk.XrmTooling.ConfigurationMigration.Wpf -O .\Tools md .\Tools\ConfigurationMigration $configMigFolder = Get-ChildItem ./Tools | Where-Object {$_.Name -match 'Microsoft.CrmSdk.XrmTooling.ConfigurationMigration.Wpf.'} move .\Tools\$configMigFolder\tools\*.* .\Tools\ConfigurationMigration Remove-Item .\Tools\$configMigFolder -Force -Recurse ## ##Download Package Deployer ## ./nuget install Microsoft.CrmSdk.XrmTooling.PackageDeployment.WPF -O .\Tools md .\Tools\PackageDeployment $pdFolder = Get-ChildItem ./Tools | Where-Object {$_.Name -match 'Microsoft.CrmSdk.XrmTooling.PackageDeployment.Wpf.'} move .\Tools\$pdFolder\tools\*.* .\Tools\PackageDeployment Remove-Item .\Tools\$pdFolder -Force -Recurse ## ##Remove NuGet.exe ## Remove-Item nuget.exePress Enter.
Step 5: Below Tools will be downloaded to D:\Dynamics_365_Development_Tools\Tools Folder.
Source Link: https://arunpotti.wordpress.com/tag/plugin-registration-tool-dynamics-365/
Subscribe to:
Posts (Atom)