Wednesday, December 17, 2008

MS CRM 5 – Secure Code on the Server - OnLive


Click here to watch the Video

In this one we chat about how to write custom code in Dynamics CRM and have that run securely in the various deployment models available including on-premises, partner-hosted and even in CRM Online.

The current version of CRM allows code on the server (for plug-ins or workflows) and that code runs in full trust. That’s the primary reason why server code is not allowed on Dynamics CRM Online where you’re sharing the server with many other tenants.

There are a number of different areas where you might need to write custom code on the server; for instance, custom workflows, custom web apps, plug-ins. It’s not hard to allow that sort of thing. Where it gets tricky is allowing developers to do that in ways that don’t compromise security and performance.

List Web Part for Microsoft Dynamics CRM 4.0


Overview
The List Web Part for Microsoft Dynamics CRM 4.0 provides a way to view and update Microsoft Dynamics CRM records using a Windows SharePoint Services 3.0 SP1 or Microsoft Office SharePoint Server 2007 SP1 Web site. Microsoft Dynamics CRM users can create shared or personal List Web Parts of Microsoft Dynamics CRM records from a SharePoint Web site, open records in Microsoft Dynamics CRM 4.0 from the List Web Part, and create connected List Web Parts.

You can download it from Microsoft website. Click here to download

Tuesday, December 9, 2008

Using New CrmDeploymentService CRM 4.0.


We have a new webservice in CRM 4.0 i.e. CrmDeploymentService
This is the end-point for this web service
http:///mscrmservices/2007/crmdeploymentservice.asmx

Using CrmDeploymentService we can do the following:
Create/Delete/Disable/Enable/Update/Set Default an organization etc.

There are two types of Microsoft Dynamics CRM deployment entities: Organization and Server. The Deployment SDK provides programmatic access for manipulating the Organization entity. It does not currently enable you to write code against the Server entity for actions such as enabling and disabling a Microsoft Dynamics CRM server.

We have a separate sdk for the Deployement. We can download the sdk at the following location
http://www.microsoft.com/downloads/details.aspx?FamilyId=2874D878-E28D-4530-A185-4DEE1FCDD12E&displaylang=en

When working with the Deployment SDK, you should be familiar with software development practices in general and Microsoft Visual C# or Microsoft Visual Basic coding practices in particular. In addition, you should be familiar with using Web services and have access to a suitable development environment.

When using the Deployment SDK, it is helpful to have the Microsoft Dynamics CRM 4.0 Software Development Kit (SDK) available as a reference.

The Microsoft Dynamics CRM 4.0 SDK is the primary development resource for Microsoft Dynamics CRM 4.0 and is a guide for developers writing server-side code, custom business logic, plug-ins, integration modules, custom workflow modules, and more. The SDK provides an architectural overview of Microsoft Dynamics CRM, the entity model, security model, Web services, and sample code.



Some basic examples of using the service

// Create an instance of CrmDeploymentService
CrmDeploymentService myDeployService = new CrmDeploymentService(); 
myDeployService.Credentials = System.Net.CredentialCache.DefaultCredentials; 
myDeployService.Url = ” valid url”;
 
// To retrieve server license type information 
RetrieveLicenseRequest myLicRequest = new RetrieveLicenseRequest();
RetrieveLicenseResponse myLicResponse = (RetrieveLicenseResponse)myDeployService.Execute(myLicRequest);
MessageBox.Show(“License Type “ + myLicResponse.LicenseType.ToString());

 
// To get the organization information
RetrieveAllRequest myRetriveAllRequest = new RetrieveAllRequest();
 
// only organization is supported ( other is Server)
myRetriveAllRequest.EntityName = EntityName.Organization;
RetrieveAllResponse myRetriveAllResponse = (RetrieveAllResponse)myDeployService.Execute(myRetriveAllRequest);
 
foreach(DeploymentEntity myEntity in myRetriveAllResponse.Entities)
{
Organization myOrganization = (Organization)myEntity;
MessageBox.Show(myOrganization.FriendlyName);
MessageBox.Show(myOrganization.Id.ToString()); 
MessageBox.Show(myOrganization.UniqueName);
}

//// To disable an organization
SetStateOrganizationRequest myOrgSetStateRequest = new SetStateOrganizationRequest();
myOrgSetStateRequest.EntityName = EntityName.Organization;
myOrgSetStateRequest.Id = new Guid(“4c7fc991-0a41-dd11-bfd9-001d7d22e1af”);
myOrgSetStateRequest.State = OrganizationState.Disabled;
SetStateOrganizationResponse myOrgSetStateResponse =(SetStateOrganizationResponse) myDeployService.Execute(myOrgSetStateRequest);
 

Monday, December 8, 2008

Error message when you log on to any organization in Microsoft Dynamics CRM 4.0: "The specified organization is disabled"


Consider the following scenario. You create two organizations in Microsoft Dynamics CRM 4.0. Then, you disable the default organization. In this scenario, when you log on to any organization in Microsoft Dynamics CRM, you receive the following error message:
Error: The specified organization is disabled


This problem occurs because a valid default organization does not exist in Microsoft Dynamics CRM.

To resolve this problem, use one of the following methods.

Method 1: Enable the default organization


Start -> Programs -> Microsoft Dynamics CRM -> Deployment Manager.
Click Organizations, right-click the default organization, and then click Enable.
Reset Internet Information Services (IIS). To do this, Start -> Run, type iisreset, and then click OK.


Method 2: Set another organization as the default organization

Start -> Programs -> Microsoft Dynamics CRM -> Deployment Manager.
Click Organizations, right-click an organization, and then click Set as Default Organization.
Reset Internet Information Services (IIS). To do this, Start -> Run, type iisreset, and then click OK.

Wednesday, December 3, 2008

RollUp 1 release for MS CRM 4.0


Microsoft has release rollup 1 for CRM 4. KB952858 can be downloaded here.

This upate is for Microsoft Dynamics CRM 4.0 Server, Microsoft Dynamics CRM for Microsoft Office Outlook, and Microsoft Dynamics CRM 4.0 E-mail Router.

Please note that if you have customized Microsoft Dynamics CRM 4.0 Help files, back up your customized files before you install this update !!!

MS CRM 4.0 upgrade issues list.


When upgrading MS CRM 3.0 to CRM 4.0, please follow the below chekclist to avoid failures:

1. Any Un supported customization will not upgrade

2. Any 3rd party tool will not upgrade like C360 components etc. It will give you trouble so first remove that and check your vendor for upgradeable version for CRM 4.0, I am sure they are upgrading it.

3. Any Connector like GP Connector, Biztalk Adapter will not upgrade

4. CRM Mobile Express 3.0 will not upgrade

5. CRM Accelerator for Seible will not supported to upgrade.

6. Sharepoint list webpart will not upgrade

7. Datamigration Pack will not upgrade

8. Your custom calls or code will not upgrade, you have to rebuild your code using new crm services, atleast you have to use crm discovery as it is multi-organizational system.

9. CRM Outlook Client will not upgrade

10. Any custom code for outlook will not upgrade

11. CRM Callouts need to modify and register with Plugin Register tool

12. Your code web to lead or web to contact need to modify by using CRM Discovery Service and updation manually

13. Any Code will not upgrade by MS CRM 4.0, you have to do all configuration manually.

14. Assembly written for workflow will not upgrade and link, you have to again link with it

Standard CRM Reports will be upgraded and link will automatically build with new CRM SRS connection. but following types of reports will not upgrade

  • The Reports has been modified to use expressions for linking will not upgrade.
  • The Report has been modified to use stored procedures will not upgrade.
  • Reports that use information about workflow, such as sales pipeline report etc will not upgrade.

Happy MS CRM 4.0 Upgrade.

Increase Attachment size in MS CRM 4.0


By default, MS CRM 4.0 file attachment size is 5 MB.
Below are the steps to increase the default size to 10 MB.

1. Open the web.config of MS CRM

2. Locate httpRuntime the key within the element and change the values to the following: httpRuntime executionTimeout = "9999"
maxRequestLength = "10240"

3. Locate httpRuntime the key within the element of the element, and change it to the following: httpRuntime maxRequestLength = "10240"

save the web.config and restart IIS.

Saturday, November 22, 2008

Integration of MS CRM (4.0) Online with SharePoint

Lot of people now a day’s talking about Integration of MS CRM (4.0) Online with SharePoint 2007.
Before we start thinking of Integration of MS CRM (4.0) Online with SharePoint we should be aware of the below restrictions of MS CRM Online.

Restriction(s) of MS CRM Online 4.0 hosted by MSFT

Plug-ins:
Plug-ins allow you to augment the Microsoft Dynamics CRM business logic with your own code, for both online and offline applications. These extensions can also be used for integration to external systems. In the previous version, this feature was known as callouts.

ExtensionsOn-PremiseHostedOnline
Plug-insYesPartner specificNo

Workflow:
Call out to external systems from your workflow rules. Create custom workflow activities that can be used by your workflow rules. In the previous version, this feature was known as workflow .NET assemblies.

ExtensionsOn-PremiseHostedOnline
Declarative workflows using workflow tools in Web applicationYesYesYes
Custom workflow activities (.NET Assemblies)YesPartner specificNo


The Probable solution would be:

1) Use standard/OOB workflows of MS CRM 4.0 Online and send out an email messages with the formatted message in the message body with all (or required) Values (Inserted / Updated / and record GUID in case of Deletion).

2) Add custom JavaScript in “OnSave()” event of the Entity, MS CRM forms where you can call out the web services (say using XmlHttpRequest / JSON) and there are chances that you will face the cross-domain Web service calls issues.

You can overcome the issue by hosting the “Internet Facing Web Services on your server” but that should be available over internet so that you can communicate CRM with exposed Web Service Server.


One more thing, I would like to share that “MS provides Partner Hosted Solutions”, you can go with it, but you have to pay (please correct me if I’m wrong), as it is paid service, I guess!!!!!

What's New in MS CRM 5.0

This posting is provided "AS IS" with no warranties, and confers no rights.

MS CRM 5.0 is currently on schedule to ship as part of the Office14 Wave (most likely sometime in 2010), and the team is only part way through the development cycle, having just completed Milestone 1 (M1). Even so, there is already much to get excited about. Here is a list of "features" that were discussed:

New Features For End Users
1. Enhanced Navigation
2. Single Page Forms
3. Data Filtering
4. In-line Visualizations
5. Team Ownership
6. Native SharePoint Integration
7. Unstructured Relationships

New Features For Administrators
1. Flexible Form Layout
2. Filtered Lookups
3. Form Headers & Footers
4. Solution Management
5. Multiple Option Sets
6. Drag & Drop Form Editor
7. Audit

New Features For Developers
1. Custom Code Sandbox
2. Plug-In Transaction Support
3. Automatic Plug-In Profiling

As you can see there is a lot to look forward to in CRM5, and I hope you are as excited as I am that the team has chosen to share this information early on.



Disclaimer: These postings are provided "AS IS" with no warranties, and confers no rights. The content of this site are my own personal opinions and do not represent my employer's view in anyway. In addition, my thoughts and opinions often change, and as a weblog is intended to provide a semi-permanent, point in time snapshot, you should not consider out of date posts to reflect my current thoughts and opinions.

Saturday, November 15, 2008

Assign Values to MS CRM attribute Types

Microsoft Dynamics CRM contains a set of attribute type classes used to define the attributes for each entity. These classes are specified in the following table.

Examples
The following sample shows you how to instantiate and set the value of each data type.
 
// Set up the CRM Service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
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;

CrmBoolean boolean = new CrmBoolean();
boolean.Value = true;
 
CrmDateTime dateTime = new CrmDateTime();
dateTime.Value = "2006/5/27T17:00:00";
 
CrmDecimal dec = new CrmDecimal();
dec.Value = (decimal)10.1;
 
CrmFloat f = new CrmFloat();
f.Value = (float)10.1;
 
CrmMoney money = new CrmMoney();
money.Value = (decimal)10.00;
 
CrmNumber number = new CrmNumber();
number.Value = 10;
 
Lookup lookup = new Lookup();
lookup.Value = user.UserId;
lookup.type = EntityName.systemuser.ToString();
 
Owner owner = new Owner();
owner.type = EntityName.systemuser.ToString();
owner.Value = user.UserId;

Picklist list = new Picklist();
list.Value = 1;

Status status = new Status();
status.Value = 1;
 
EntityNameReference reference = new EntityNameReference();
reference.Value = EntityName.systemuser.ToString();

Key key = new Key();
key.Value = user.UserId;
 
 

Friday, October 10, 2008

Working with ASP.NET Request URL Properties.

Let assume below is the Web URL:
http://localhost:5555/ISV/Customizations/Default.aspx?orgname=microsoftcrm

HttpRequest path and URL properties:

Request.ApplicationPath:/ISV
Request.CurrentExecutionFilePath:/ISV/Customizations/Default.aspx
Request.FilePath:/ISV/Customizations/Default.aspx
Request.Path:/ISV/Customizations/Default.aspx
Request.PathInfo:
Request.PhysicalApplicationPath:D:\Inetpub\wwwroot\ISV\Customizations\
Request.QueryString:/ISV/Customizations/Default.aspx?orgname=microsoftcrm
Request.Url.AbsolutePath:/ISV/Customizations/Default.aspx
Request.Url.AbsoluteUri:http://localhost:5555/ISV/Customizations/Default.aspx?orgname=microsoftcrm
Request.Url.Fragment:
Request.Url.Host:localhost
Request.Url.Authority:localhost:5555
Request.Url.LocalPath:/ISV/Customizations/Default.aspx
Request.Url.PathAndQuery:/ISV/Customizations/Default.aspx?orgname=microsoftcrm
Request.Url.Port:5555
Request.Url.Query:?orgname=microsoftcrm
Request.Url.Scheme:http
Request.Url.Segments:/ISV/Customizations/Default.aspx

Hope this post is useful for all you !!!!

Wednesday, September 24, 2008

Check Number of notes attached to a Crm Record.


Write below code on save of the entity.

var CRM_FORM_TYPE_CREATE = 1;
 
if (crmForm.FormType == CRM_FORM_TYPE_CREATE)
{
    var obj=document.frames(”notescontrol”).document;
    var textarea=obj.getElementsByTagName(’TEXTAREA’);
 
    if (textarea.length < 1)
    {
        alert (”please eneter somenotes”);
 
        // Cancel the save
        event.returnValue = false;
    }
}

CRM Form Types


Is the user creating a new record?
crmForm.FormType == 1

Is the user updating an existing record
crmForm.FormType ==2

Is the user unable to update this record?
crmForm.FormType == 3

Is this record deactivated?
crmForm.FormType == 4

Is the user using the Quick Create form?
crmForm.FormType == 5

Is the user using the Bulk Edit form?
crmForm.FormType == 6

What is the unique ID for this record?
= crmForm.ObjectId

What type of record is this?
= crmForm.ObjectTypeCode

What type of record is this (Entity Name)?
= crmForm.ObjectTypeName

Is the user using the Outlook Client?
crmForm.IsForOutlookClient==true

Is the user using the Outlook Light Client?
crmForm.IsForOutlookLightClient == true

Is the user working On line?
crmForm.IsOnline==true

Have any fields in this form been changed?
crmForm.IsDirty==true

Hide all Tabs on CRM Form



//Below is the javascript code, which will hide all tabs on CRM form.
document.getElementById("crmTabBar").style.display = "none";


//If you want to hide a specific tab, use below code:
document.getElementById("tab0Tab").style.display = "none";


//Here "tab0Tab" is first tab on the Crm Form.

Tuesday, September 23, 2008

How to attach onClose event to MS CRM Entity.


When you work with CRM Forms, if you want to capture / attach a onClose() Event, just use below javascript code.

window.onunload = function() {
//add code here
}

Delete / DisAssociate Many to Many Relationship Record.


When you say DisAssocaiating a Many to Many Relationship Record, then you usually deattach the record, you won't delete the record.

Below function will DisAssocaiate a record. Here, you need to pass three parameter values
Parent Entity Guid,
Child Entity Guid, and
Relationship Name.

public bool DisassociateManyToManyEntityRecords(Moniker Moniker1, Moniker Moniker2, string strEntityRelationshipName)
{
try
{
// Create a request.
DisassociateEntitiesRequest request = new DisassociateEntitiesRequest();

        // Assign the request a moniker for both entities that need to be disassociated.
request.Moniker1 = Moniker1;
request.Moniker2 = Moniker2;

        // Set the relationship name that associates the two entities.
request.RelationshipName = strEntityRelationshipName.Trim();
        // Execute the request.
DisassociateEntitiesResponse response = (DisassociateEntitiesResponse)Service.Execute(request);

        return true;
}

    catch (SoapException ex)
{
return false;
}
}

Retrieve Associated Many to Many Relationship Records.


In our last post we have seen "Creating Records for Many to Many Relationship in MS CRM".

Now how do you retrieve the (many to many) records ?

Its Very Easy .... :) I'm serious.... See below function........

Lets assume, we have "Hotel Reservation" and "Guest" Entity. We have many to many relationship between Guest and HotelReservation Entity.

Below function will return the list of Hotel Reservations (Guids) for the Guest.



public List GetAllAssocaitedRecords(Guid GuestGuid) 
{ 
    string strEntityRelationshipName = "Specify Relationship Name";
 
    List ObjHotelReservationGuids = new List();
 
    string fetchXml = @"<fetch mapping=""logical""> <entity name=""@HotelReservationContactRelation"">
                            <all-attributes />
                            <filter>
                                <condition attribute=""contactid"" operator=""eq"" value =""@GuestGuid"" />
                            </filter>
                            </entity>
                        </fetch>";
 
 
    fetchXml = fetchXml.Replace("@GuestGuid", GuestGuid.ToString());
    fetchXml = fetchXml.Replace("@HotelReservationContactRelation", strEntityRelationshipName );
 
    string strResult = Service.Fetch(fetchXml);
 
    XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(strResult);
    XmlNodeList nodeList = xmlDoc.SelectNodes("resultset/result");
 
    if (nodeList.Count > 0)
    {
        foreach (XmlNode xmlNode in nodeList)
        {
            ObjHotelReservationGuids.Add(new Guid(xmlNode.SelectSingleNode("neuguest_hotelreservationid").InnerText));
        }
    }
    
    return ObjHotelReservationGuids;
}
 


Happy Coding !!!!!


Thursday, September 11, 2008

Creating Records for Many to Many Relationship in MS CRM


Have you ever created Many to Many Relationship in MS CRM 4.0 ?

Use AssociateEntitiesRequest Class (CrmService)
Contains the data needed to add a link between two entity instances in a many-to-many relationship.
When you create Many to Many Relationship between two entities (system / Custom), MS CRM 4.0 creates New Table in MS CRM database. The name would be the "Relationship name" which you specified while creating Many to Many relationship.

Now, how do u associate a record to Entities?

Let's say, You have One "Entity: Contact" and other "Entity: New_CustomEntity".


Step 1: Create the record for first "Entity: Contact" (you will get a GUID for this record)

Step 2: Create the record for Second "Entity: New_CustomEntity" (you will get a GUID for this record)

Step 3: When you create Many to Many Relationship between two entities, you will specify "Relationship name" Eg: Contact_New_CustomEntity_ManyToMany

Step 4: Call below method and pass both the Entity Information with Relationship name. For more info see below example.


// Code Create Moniker for first Entity: Contact
Moniker Moniker1 = new Moniker();
Moniker1.Id = new Guid("SPECIFY GUID For the record");
Moniker1.Name = EntityName.contact.ToString();
 
// Code Create Moniker for second Entity: New_CustomEntity
Moniker Moniker2 = new Moniker();
Moniker2.Id = new Guid("SPECIFY GUID For the record");
Moniker2.Name = EntityName.New_CustomEntity.ToString();
 
string strManyToManyRelationshipName = "Contact_New_CustomEntity_ManyToMany"; 
 
if (ObjCrmHelper.AssociateManyToManyEntityRecords(Moniker1, Moniker2, strManyToManyRelationshipName))
MessageBox.Show("Associated Entities Record.");
else
MessageBox.Show("Error Occoured.");


//Method which will associate the records.
public bool AssociateManyToManyEntityRecords(Moniker Moniker1, Moniker Moniker2, string strEntityRelationshipName)
{
try
{
// Create an AssociateEntities request.
AssociateEntitiesRequest request = new AssociateEntitiesRequest();

        // Set the ID of Moniker1 to the ID of the lead.
request.Moniker1 = Moniker1;

        // Set the ID of Moniker2 to the ID of the contact.
request.Moniker2 = Moniker2;

        // Set the relationship name to associate on.
request.RelationshipName = strEntityRelationshipName;

        // Execute the request.
Service.Execute(request);

        return true;
}

    catch (SoapException ex)
{
return false;
}
}

/******************/
Happy Coding !!!!!!


Thursday, August 21, 2008

Create and Send Email Activity

You can easily craete and send an email activity in MS CRM 3.0 / 4.0.

If you experience "MS CRM 4.0: Generic SQL error 0x80044150" error, Please enable the impersonation in the web.config:

Here is the simple code to Create and Send Email Activity:

public bool CreateAndSendEmail(Lookup EmailFrom, Lookup EmailTo, string EmailSubject, string EmailDescription, Lookup RegardingObject)
{
    try
    {
        #region Create Email Object
 
            email ObjEmail = new email();
 
            if(EmailFrom != null)
            {
                activityparty ObjFrom = new activityparty();
                ObjFrom.partyid = EmailFrom;
                ObjEmail.from = new activityparty[] { ObjFrom };
            }
 
            activityparty ObjTo = new activityparty();
            ObjTo.partyid = EmailTo;
            ObjEmail.to = new activityparty[] { ObjTo };
 
            // Assign Subject
            ObjEmail.subject = EmailSubject;
 
            // Assign Description
            ObjEmail.description = EmailDescription;
 
            CrmSdk.CrmBoolean direction = new CrmSdk.CrmBoolean();
            direction.Value = true;
            ObjEmail.directioncode = direction;
 
            //Regarding Case
            if(RegardingObject != null)
                ObjEmail.regardingobjectid = RegardingObject;
 
            //Create Email
            try
            {
                Guid EmailGuid = Service.Create(ObjEmail);
 
                // Create a SendEmail request.
                SendEmailRequest emailRequest = new SendEmailRequest();
                emailRequest.EmailId = EmailGuid;
                emailRequest.TrackingToken = "";
                emailRequest.IssueSend = true;
 
                // Send the email message.
                SendEmailResponse emailResponse = (SendEmailResponse)Service.Execute(emailRequest);
 
                return true;
            }
 
            catch (SoapException)
            {
                return false;
            } 
 
        #endregion Create Email Object
    }
    
    catch (SoapException)
    {
        return false;
    }
}


Hope you find this code helpful.
Happy Coding.

Tuesday, August 12, 2008

Working with Null Values in MS CRM


When you update an entity instance there is a mechanism you can use to differentiate the absence of a value from a null value. To set an attribute value to null you must set both IsNull and IsNullSpecified to true. For attributes of type String, you must assign the value to String.Empty. This same mechanism is used when you create a query to find a null value.

Another option is to use the type helper code available in Microsoft.Crm.Sdk assembly and in the CRMHelpers classes.

Example

The following code example shows you how to create null instances of the various Microsoft Dynamics CRM attribute types.

CrmBoolean boolean = new CrmBoolean();
boolean.IsNull = true;
boolean.IsNullSpecified = true;
 
CrmDecimal dec = new CrmDecimal();
dec.IsNull = true;
dec.IsNullSpecified = true;
 
CrmFloat f = new CrmFloat();
f.IsNull = true;
f.IsNullSpecified = true;
 
CrmMoney money = new CrmMoney();
money.IsNull = true;
money.IsNullSpecified = true;
 
CrmNumber number = new CrmNumber();
number.IsNull = true;
number.IsNullSpecified = true;
 
Lookup lookup = new Lookup();
lookup.IsNull = true;
lookup.IsNullSpecified = true;
 
PickList list = new PickList();
list.IsNull = true;
list.IsNullSpecified = true;
 
Status status = new StatusV();
status.IsNull = true;
status.IsNullSpecified = true;
 
Owner owner = new Owner();
owner.IsNull = true;
owner.IsNullSpecified = true;
 


Example

The following code example shows you how to create null instances of the various Microsoft Dynamics CRM attribute types using the type helper classes.

CrmBoolean boolean = CrmBoolean.Null;
 
CrmDecimal dec = CrmDecimal.Null;
 
CrmFloat flt = CrmFloat.Null;
 
CrmMoney money = CrmMoney.Null;
 
CrmNumber number = CrmNumber.Null;
 
Lookup lookup = Lookup.Null;
 
Picklist list = Picklist.Null;
 
Status status = Status.Null;
 
Owner owner = Owner.Null;

Set Default Value to a Lookup Attribute using JavaScript


Below Example will set the Default Primary Contact ID for Account Entity.

if(crmForm.all.primarycontactid.DataValue == null)
      
        //Create an array to set as the DataValue for the lookup control.

        var lookupData = new Array();

       //Create an Object add to the array.
        var lookupItem= new Object();
 
       //Set the id, typename, and name properties to the object.
        lookupItem.id = 'SPECIFY GUID of an Entity';
        lookupItem.typename = 'SPECIFY Entity Name';
        lookupItem.name = 'SPECIFY Attribute DISPLAY Value'; 
       // Add the object to the array.
          lookupData[0] = lookupItem; 
      // Set the value of the lookup field to the value of the array.
        crmForm.all.primarycontactid.DataValue = lookupData; 
} 

Thursday, August 7, 2008

Create Note and Assign to a Entity.


Sample code which will create a note and attach to the specified Entity (Specify Entity Name and GUID of the Entity Record)


CrmService service = GetCrmService("http://192.168.150.221:5555", "ORGANIZATION", "USERNAME", "PASSWORD", "DOMAIN");
 
annotation note = new annotation();
 
note.subject = "NOTE SUBJECT";
note.filename = @"schema.xsd";
note.mimetype = "text/html";
 
string encodedData = string.Empty;
using (FileStream fs = new FileStream(@"c:\schema.xsd", FileMode.Open, FileAccess.Read))
{
byte[] byteData = new byte[fs.Length];
fs.Read(byteData, 0, byteData.Length);
encodedData = System.Convert.ToBase64String(byteData);
}
note.documentbody = encodedData;
 
note.objectid = new Lookup();
note.objectid.type = "SPECIFY ENTITY_NAME";
note.objectid.Value = new Guid("F27A627B-DF1A-DD11-AEA5-0003FF90FBC7");
note.objecttypecode = new EntityNameReference();
note.objecttypecode.Value = "SPECIFY ENTITY_NAME";
 
Guid annotationId = service.Create(note); 


---- HERE you can Initialize CRM SERVICE Object.....

public static CrmService GetCrmService(string crmServerUrl, string organizationName, string userName, string password, string domain)
{
    // Get the CRM Users appointments
    // Setup the Authentication Token
    CrmAuthenticationToken token = new CrmAuthenticationToken();
    token.OrganizationName = organizationName;
 
    CrmService service = new CrmService();
 
    if (crmServerUrl != null &&
    crmServerUrl.Length > 0)
    {
        UriBuilder builder = new UriBuilder(crmServerUrl);
        builder.Path = "//MSCRMServices//2007//CrmService.asmx";
        service.Url = builder.Uri.ToString();
    }
 
    service.Credentials = new System.Net.NetworkCredential(userName, password, domain);
    service.CrmAuthenticationTokenValue = token;
 
    return service;
}


Happy Coding....


Sunday, July 27, 2008

WampServer 2.0 Port Configuration


Configure WampServer 2.0 on different (change port from 80 to 81)

I assume your server Configuration:
Apache Version: 2.2.
PHP Version: 5.2.6

Now that you have WampServer 2.0 installed, you'll want to use it along side with other servers such as IIS. This is easily done by changing the port that WampServer 2.0 listens to. I suggest changing the port from 80 to 81.

Use Notepad or WordPad to open the files below.

Open the httpd.conf file for the Apache server. On my machine, it's located here C:\wamp\bin\apache\apache2.2.8\conf\httpd.conf
Do a search for "Listen 80" and replace it with "Listen 81".
Save and close the file.

Open the wampmanager.tpl file. On my machine, it's located here: C:\wamp\wampmanager.tpl
Do a search for "http://localhost/" and replace it with "http://localhost:81/" (There are three total).
Do a search for "${w_testPort80}" and replace it with "${w_testPort81}".
Save and close the file.

Open the testPort.php file. On my machine, it's located here: C:\wamp\scripts\testPort.php
Do a search for "80" and replace it with "81" (There are three total).
Save and close the file.

Open the english.lang file. On my machine, it's located here: C:\wamp\lang\english.lang
Do a search for "$w_testPort80 = 'Test Port 80';" and replace it with "$w_testPort81 = 'Test Port 81';".
Save and close the file.

Right click on the WampServer icon and click on "Exit".
Restart your WampServer.

Congratulations! You have now changed your WampServer 2.0 to port 81. All of your links (localhost, phpMyAdmin, SQLiteManager) are configured to the new port and you can even test port 81 by going to the Apache Services.
If you found this helpful (or if you didn't), please
let me know.

Thursday, February 14, 2008

Generate MS CRM Entity Schema.


Hi,
"GenerateEntitySchema" tool generates a MS CRM Entity Schema.
Example "account": it generates the schema for all the attributes including (picklist values).
Have a look at this tool. (See screenshot)





you can download Generate MS CRM Entity Schema from http://www.codeplex.com/GenerateEntitySchema

As I'm working on this tool i'll release the source code soon.

All feedbacks are most welcome. !!!


Happy MS CRM Development.

Monday, February 4, 2008

Microsoft Dynamics CRM Demonstration Tools (for Microsoft Dynamics CRM 4.0)


Brief Description
The Microsoft Dynamics CRM 4.0 Demonstration Tools provide a simple user interface that allows you to easily enter and edit data to populate or modify your instance of Microsoft Dynamics CRM. It also allows you to load and store your data in XML format, so that you can reuse your data in the future.

You can download this tool from Microsoft website, for more information
Visit: http://www.microsoft.com/downloads/details.aspx?FamilyID=634508DC-1762-40D6-B745-B3BDE05D7012&displaylang=en

Sunday, February 3, 2008

MS CRM 4.0 Plugins not working


If you are working with the default Plugin sample which is shipped with MS CRM 4.0 SDK, unforunately if it doesn't work then simple regenerate the Strong Name Key (snk).

Steps:
1. Open the Sample Plugin Solution.
2. Right Click on the Solution -> Properties.
3. Click on "Signing" Tab (look at Left Navigation Bar).
4. Select "New" from "Strong name key file dropdown"
Enter "SamplePluginKey" in Name text box
uncheck "Protect my key file with a password"
Click on "OK"
Click on "Yes" which it asks for replacing the existing strong name key file.
5. Save All Files.
6. Compile the Solution.


Here you are all set to go :)
Isn't it simple ?

Comments are most welcome !!!!!!!!

Generate postImageEntityXml (MSCRM 3.0) equivalent in MS CRM 4.0 Plugins


If you worked on MS CRM 3.0 callouts, in the method signature of Pre/Post you get a string called as postImageEntityXml.

postImageEntityXml is nothing but an XML string that describes the entity after the assign operation was performed. This is a serialized version of DynamicEntity.

You can create the DynamicEntity Object using the Context Object.
Eg:
DynamicEntity entity = (DynamicEntity)context.InputParameters.Properties["Target"];

Below is the code for MS CRM 4.0 which is equivalent of the postImageEntityXml string value in 3.0.

To implement this code functionality in plugin, use the Sample Plugin Code:
------------------------------------------------------------------------
public class postImageEntityXmlExample : IPlugin
{

// This fucntion gets called from the EXECUTE method of plugin (marked in bold)

private string SerializeDynamicEntity(Microsoft.Crm.Sdk.DynamicEntity entity)
{
XmlSerializer serializer = new XmlSerializer(typeof(Microsoft.Crm.Sdk.DynamicEntity));
StringWriter writer = new StringWriter(CultureInfo.InvariantCulture);
serializer.Serialize(writer, entity);
return writer.ToString();
}


private void WriteToFile(string message)
{
try
{
StreamWriter sw = new StreamWriter(@"c:\ErrorLog.txt", true);
sw.WriteLine();
sw.WriteLine(System.DateTime.Now.ToString());
sw.WriteLine();
sw.WriteLine(message);
//Cleanup
sw.Close();
}
catch (Exception ex)
{
//TODO Develop Code, if an Error comes while write to File
}
}

public void Execute(IPluginExecutionContext context)
{
DynamicEntity entity = null;

if (context.MessageName=="Create" context.MessageName == "Update")
{
if (context.InputParameters.Properties.Contains("Target") &&
context.InputParameters.Properties["Target"] is DynamicEntity)
{
entity = (DynamicEntity)context.InputParameters.Properties["Target"];

//call the below code to Serialize Dynamic Entity into postImageEntityXml
WriteToFile("\XML string \n" + SerializeDynamicEntity(entity));
}
}
}
}

---------------------------------------------------------------------------

Isn't it simple?
Happy MS CRM Development.

Comments are welcome..... :)

Tuesday, January 22, 2008

Microsoft Dynamics CRM 4.0: 90-Day Trial Versions

Brief Description:
Microsoft Dynamics CRM 4.0 90-day trial versions for released languages.


http://www.microsoft.com/downloads/details.aspx?familyid=A9C110FD-AAC8-4D2A-B401-7801B1866E82&displaylang=en

Microsoft Dynamics CRM 4.0 Server Readme

Brief Description:
This document provides important late-breaking information for Microsoft Dynamics CRM 4.0 Server.


http://www.microsoft.com/downloads/details.aspx?familyid=1DB2D16D-7885-4561-A461-20B948913B3F&displaylang=en

Microsoft Dynamics CRM 4.0 Internet Facing Deployment Scenarios

Brief Description:
This document covers how to set up the Microsoft Dynamics CRM 4.0 Web site to make it available from the Internet.

http://www.microsoft.com/downloads/details.aspx?familyid=3861E56D-B5ED-4F7F-B2FD-5A53BC71DAFC&displaylang=en

Microsoft Dynamics CRM 4.0 Implementation Guide

Brief Description:
This guide contains comprehensive information about how to plan, install, and maintain Microsoft Dynamics CRM 4.0.


http://www.microsoft.com/downloads/details.aspx?familyid=1CEB5E01-DE9F-48C0-8CE2-51633EBF4714&displaylang=en

Microsoft Dynamics CRM 4.0 Software Development Kit

Brief Description:
Sample data can be used for marketing and sales presentations or for training people to use Microsoft Dynamics CRM 4.0.


http://www.microsoft.com/downloads/details.aspx?familyid=82E632A7-FAF9-41E0-8EC1-A2662AAE9DFB&displaylang=en

MS CRM 4.0 Sample Data (On-Premise) ready for download

Microsoft Dynamics CRM 4.0 Sample Data (On-Premise) ready for download...

http://www.microsoft.com/downloads/details.aspx?FamilyID=d5f77ee7-3d01-4944-b5dc-c8cdc8123df4&DisplayLang=en