Archive for the ‘Microsoft .NET’ Category

One of our client wanted to move CRM Server from One Data Centre to different data centre but due to some constraint we could not move it by creating New Organization or by new deployment. We had only left option was update IP address manually. Recently we moved our CRM Server from one data centre [...]

public void SendMail(ICrmService service,Guid ownerID, Guid fromGuid, ArrayList toGuid,Guid recordRegardingID,Guid templateId,Enum  enitityName) { // Create an instance of email email myEmail = new email(); //set the owner of the mail myEmail.ownerid = new Owner(); myEmail.ownerid.type = EntityName.systemuser.ToString(); myEmail.ownerid.Value = ownerID; // specify the from part of the email activityparty from = new activityparty(); from.partyid = [...]

private bool RevokeAccessToEntity(ICrmService service, Guid guidValue, Guid entityID, string EntityName) { bool isSuccess = false; // Create the SecurityPrincipal object. SecurityPrincipal principal = new SecurityPrincipal(); // PrincipalId is the GUID of the team whose access is being revoked. principal.Type = SecurityPrincipalType.Team; principal.PrincipalId = guidValue; // Create the target for the request. TargetOwnedDynamic target = new [...]

using System; using System.Collections.Generic; using System.Text; using Microsoft.Crm.Sdk; using Microsoft.Crm.SdkTypeProxy; using Microsoft.Crm.Sdk.Query; using System.Web.Services.Protocols; namespace CRM.Customization.AutoNumber { public class AutoNumberPlugIns:IPlugin { DynamicEntity entity = null; int startNumber; string prefix = string.Empty; string seperator = string.Empty; int nextMaxNumber; string uniqueId = string.Empty; #region IPlugin Members public void Execute(IPluginExecutionContext context) { if (context.InputParameters.Properties.Contains(“Target”) && context.InputParameters.Properties["Target"] is DynamicEntity) [...]

// Set up the CRM Service. CrmAuthenticationToken token = new CrmAuthenticationToken(); // You can use enums.cs from the SDK\Helpers folder to get the enumeration for AD Authentication. token.AuthenticationType = 0; token.OrganizationName =”AdventureWorksCycle”; CrmService service = new CrmService(); service.Url =”http://<servername>:<port>/mscrmservices/2007/crmservice. asmx”; service.CrmAuthenticationTokenValue = token; service.Credentials = System.Net.CredentialCache.DefaultCredentials; // Create the column set object that indicates the [...]

CrmDiscovery service is a global installable level service that allow the caller to determine the correct organization and URL for his/her need. Below example show how to create and configure CrmDiscoveryService Web Service proxy.   // Create and configure the CrmDiscoveryService Web service proxy. CrmDiscoveryService discoveryService = new CrmDiscoveryService(); discoveryService.UseDefaultCredentials = true; discoveryService.Url =”http://localhost/MSCRMServices/2007/AD/CrmDiscoveryServic e.asmx”; [...]

Create two field as we created.. 1) New_uniqueid ( Int) 2) New_id( nvarchar). If you want AutoNumber as Int , no need to create two fields ,but we wanted AutoNumber as in specific format(OP/DEC08/0000000001) so we reqired to two field. Steps for AutoNumber: 1) Retrieved the maximum number for entity based on field new_uniqueid. 2) [...]

To retrieve data from CRM Database( FilteredView)….. SqlConnection connection = new SqlConnection(“DataSource=<dsName>;Initial Catalog=<databaseName> ;Integrated Security=SSPI;”); string sqlQuery = @” select max(new_uniqueid) from FilteredView” ; SqlCommand cmd = new SqlCommand(sqlQuery, connection); connection.Open();   /// Write Logic here   connection.Close();   But this code wasn’t returning any results .It was because callout/plugin run under the context of [...]

Here we will be calling the default helloworld webservice that is already created for us when we open a asp.net webservice project template in Visual Studio. We’ll just have a textbox(html control) which will display us the Hello World! response returned from the web service. This is the step we need to follow 1) Create [...]