CRM Blog

Wednesday, March 04, 2009 - Posts

E-mail Field - Open In Outlook or E-mail Activity
by Danny Varghese 03.04.09

Comments    9 Comment(s)

Here's a simple JavaScript customization to enable an e-mail field, once filled in, have a user double-click it and open your default e-mail client with the address in the "To" field.

 

if(crmForm.FormType == 1 || crmForm.FormType == 2)

{

                crmForm.all.emailaddress1.ondblclick = function()

                {

                                var email = crmForm.all.emailaddress1.DataValue;

                                if ((email != null) && (email.length > 0))

                                {

                                     window.navigate("mailto:" + email);

                                }

                                                               

                }

}

 

Now if you want to make CRM open an e-mail activity instead of the default e-mail client, you can use the following code (when sending the email, CRM will use email address 1 regardless of what field was dobule clicked):

 

if(crmForm.FormType == 1 || crmForm.FormType == 2)

{

                crmForm.all.emailaddress1.ondblclick = function()

                {

                                var email = crmForm.all.emailaddress1.DataValue;

                                if ((email != null) && (email.length > 0))

                                {

                                     window.execScript(locAddActTo(4202))

                                }

                                                               

                }

}

Filed under:
Example of Dynamic Entity Create
by Danny Varghese 03.04.09

Comments    No Comments

There have been numerous requests on other blogs about sample code to on how to create entities in CRM.  One way is to use the CRM web service to create business entities, however by doing so, you're only limited to out-of-the-box entities with system attributes.  To retrieve anything more "dynamic," you'll have to employ other methods.  Please remember that in order to create any record, you must have the proper permissions on that entity.

 

Below is a code example of how to create a record using dynamic entities:

 

public void CreateEntity(ICrmService service)

{

//variable initialization

DynamicEntity entity = new DynamicEntity();                                                 //target entity to update

TargetCreateDynamic targetCreate = new TargetCreateDynamic();          //used to update entity

CreateRequest createRequest = new CreateRequest();                                //request to create entity

 

entity.Name = <entity name>

 

//add the properties                   

entity.Properties.Add(<property>);

Entity.Properties.Add(<property>);

 

//set the target to update, and the request to update for

targetCreate.Entity = entity;

createRequest.Target = targetCreate;

 

//execute the update request

service.Execute(createRequest);

}

 

Hope this helps, happy coding!

Filed under: