112 Tuesday, December 27, 2016 |
Suresh Maurya
Dynamics CRM Consultant at IBM

Form events in MS CRM?

  • OnLoad Event
    • The OnLoad event occurs after the form has loaded.
    • It cannot prevent the window from loading.
    • Use the OnLoad event to apply logic about how the form should be displayed, to set properties on fields, and interact with other page elements.
  • OnSave Event
    • The OnSave event occurs when:
    • The user clicks the Auto save button button in the lower right corner of the form, even when there is no changed data to be saved.
    • Code executes the Xrm.Page.data.entity.save method, even when there is no changed data to be saved.
    • The user navigates away from the form and there is unsaved data in the form.
    • With auto-save is enabled, 30 seconds after data has changed and there is unsaved data in the form.
    • Code executes the Xrm.Page.data.save method and there is unsaved data in the form.
    • Code executes the Xrm.Page.data.refresh method passing a true value as the first parameter and there is unsaved data in the form.
  • Field OnChange Event
    • The OnChange event occurs when:
    • The data in a form field has changed and focus is lost.
    • Radio buttons or check boxes clicked.
    • Calling Xrm.Page.data.entity attribute.fireOnChange method.
    • The OnChange event does not occur if the field is changed programmatically using the setValue method. If you want call attribute.fireOnChange method.
  • Tab TabStateChange Event
    • The TabStateChange event occurs when the DisplayState of the tab changes due to user interaction or when the setDisplayState method is applied in code.
    • Use this event when you wish to change the src property of an IFRAME within the tab.
    • If you set the IFrame src property in the OnLoad event for an IFRAME within a collapsed tab, the value will be overwritten when the tab is expanded.
  • IFRAME OnReadyStateComplete Event
    • The OnReadyStateComplete event indicates that the content of the IFRAME has loaded and can be accessed in code.
    • Use this event when referencing IFRAME controls within your scripts.
  • Lookup Control PreSearch Event
    • The lookup control has a PreSearch event that occurs just before the control launches a dialog to search for records.
    • There is no UI to set event handlers for this event.
    • You must use the addPreSearch and removePreSearch methods on the lookup control to add or remove event handlers for this event.
  • OnProcessStatusChange Event
    • This event occurs when the status of a process instance changes.
    • Use the Xrm.Page.data.process.addOnProcessStatusChange method to add event handlers for this event
    • and the Xrm.Page.data.process.removeOnProcessStatusChange method to remove them.
  • OnStageChange Event
    • This event occurs when the user clicks the Next Stage or Move to previous stage buttons in the user interface
    • or when a developer uses the Xrm.Page.data.process.moveNext or Xrm.Page.data.process.movePrevious methods.
    • You can’t cancel the stage change using code in a handler for this event.
  • OnStageSelected Event
    • This event occurs when a stage of a business process flow control is selected.
    • You can’t cancel the stage selection using code in a handler for this event.
  • Knowledge Base Search Control Events
    • The knowledge base search control can only be added to forms for organizations that has the knowledge management feature enabled. This control has two events (OnResultOpened and OnSelection) that developers can programmatically assign event handlers to.
  • Subgrid OnLoad event
    • Subgrids load asynchronously from the form so you can’t reliably get access to the data in the subgrid in the form OnLoad event. But you can set an event handler for the OnLoad event of the subgrid.
    • This event will occur each time the data in the grid is refreshed, this includes when users sort the columns of the grid.
  • Editable Grid Events
    • OnRecordSelect
      • The OnRecordSelect event occurs when a single row (record) is selected in the editable grid. This event won't occur if a user selects different cells in the same row, or selects multiple rows.
    • OnChange
      The OnChange event occurs when a value is changed in a cell in the editable grid and the cell loses focus. This event can also occur when an attribute value is updated using the setValue method.
    • OnSave
      • The OnSave event occurs before sending the updated information to the server, and when any of the following occurs:
        There is a change in the record selection.
        The user explicitly triggers a save operation using the editable grid’s save button.
        The user applies a sort, filter, group, pagination, or navigation operation from the editable grid while there are pending changes.

Organization Service Context Class in Microsoft Dynamics CRM

OrganizationServiceContext is alternative to OrganizationServiceProxy to connect to Microsoft Dynamics CRM programmatically.

OrganizationServiceContext class can be generated by the code generation tool (CrmSvcUtil.exe).

Advantages of OrganizationServiceContext

  • It lets you track changes, manage identities and relationships.
  • Allows LINQ queries against Microsoft Dynamics CRM data.
  • Tracked changes can be commited in a single request with OrganizationServiceContext.Save method.

Generate OrganizationServiceContext class

To generate this class, provide a value for the /serviceContextName parameter when you generate early bound types.

For On-premises

CrmSvcUtil.exe /url:http://<serverName>/<organizationName>/XRMServices/2011/Organization.svc    /out:<outputFilename>.cs /username:<username> /password:<password> /domain:<domainName>    /namespace:<outputNamespace> /serviceContextName:<serviceContextName>

 

For Microsoft Dynamics CRM Online

CrmSvcUtil.exe /url:https://<organizationUrlName>.api.crm.dynamics.com/XRMServices/2011/Organization.svc    /out:<outputFilename>.cs /username:<username> /password:<password>     /namespace:<outputNamespace> /serviceContextName:<serviceContextName>

Using OrganizationServiceContext class

To instantiate the context class, you must pass the class constructor an object that implements the IOrganizationService interface.

With OrganizationService

//connection is the connection string name in config file
IOrganizationService _service = new OrganizationService("connection"); AdventureWorksCycleServiceContext context = new AdventureWorksCycleServiceContext(_service);

With OrganizationServiceProxy

//For early bound types to work correctly, they have to be enabled on the proxy.
_serviceProxy.EnableProxyTypes();
AdventureWorksCycleServiceContext context = new AdventureWorksCycleServiceContext(_serviceProxy);

After you create the organization service context object, you can begin to track create, modify, or delete entities. For example, the following code example shows how to instantiate a new contact, and then save it to a Microsoft Dynamics CRM server by using the service context object.

//  Create a new contact record;
AdventureWorksCycleServiceContext context = new AdventureWorksCycleServiceContext (_serviceProxy);
Contact contact = new Contact() 
 {
   FirstName = "Pamela",
   LastName = "Brown",
   Address1_Line1 = "123 Easy St.",
   Address1_City = "Atlanta",
   Address1_StateOrProvince = "GA",
   Address1_PostalCode = "32254",
   Telephone1 = "425-555-5678"   };
context.AddObject(contact);
context.SaveChanges();

 

 

Illustrated guide to entity creation in Dynamics CRM

Even fundamental actions like creating a new entity in CRM are subject to irreversible hasty choices that we all come to regret later.

Introducing CRM Tipsters Illustrated Guide to Entity Creation in Dynamics CRM.

Microsoft Dynamics CRM 2013 for Tablets - Customizations

Microsoft Dynamics CRM Online 2015 Update 1 - CRM for Phone New Features

funny CRM video of a dude drinking coffee

[Job] - Microsoft Dynamics CRM, India

Company: Accenture

Location: Hyderabad, India

Job description

Role:- Developer

Years of experience:- 3 to 4 years

Must to have:-

  •  Must have worked on CRM 011
  •  Must have worked on Dynamics CRM 4 or 011 version
  •  Should be able to create and debug Plugins - Should be able to create and debug Custom Workflow activities
  •  Should be able to do Ribbon customization - Understanding of Solutions - Understanding of the security in Dynamics CRM
  •  Should have understanding of using Developer Toolkit for Dynamics CRM

Good to have:

  •  Exp in Silverlight - SSRS
  •  Strong design and development skills
  •  Ability to design and develop flows
  •  Effectively communicates to internal and external stake-holders"


Basic qualifications

Full Time Graduation

Dynamics CRM Security Scenario

Here's a demo of creating a relatively locked-down security role.

Some of the points demonstrated:

  • how the Append and Append To privileges work;
  • what's the difference between user-level Create privilege and higher level Creative privileges;
  • how to configure task privileges (e.g., no exporting to Excel, no bulk edits).

Sales Literature: Attach Sales Literature to Email

To attach sales literature to an email, follow these steps:

  • On the Home tab of the Microsoft Outlook Inbox, click New E-mail in the New group.
  • In the To and Subject lines, enter appropriate information.
  • On the Message tab, in the CRM group, click Set Regarding.
  • In the Find section of the Set Regarding drop-down list, click More.
  • In the Look Up Record dialog, select Contact in the Look for drop-down list, enter a contact name in the Search box, and then press Enter.
  • Select the contact record, and click OK. After a few seconds, the email should be tracked in Microsoft Dynamics CRM, which is indicated by additional options becoming available in the CRM group in the Message tab.
  • Click Attach Sales Literature in the CRM group.
  • Click Send.

Microsoft Dynamics CRM Online - Mail Merge

This video will guide you through creating mail merge documents from Microsoft Dynamics CRM Online. First we create a mail merge template. Then we walk through how to create a Quick Campaign Email using mail merge. Finally, we show how to create mailing lables using mail merge.

Retrieve Records In Dynamics CRM Using QueryByAttribute

Following example demonstrates how to retrieve records in dynamics crm using QueryByAttribute.

Connection string

<connectionStrings>
<add name="connection" connectionString="Url=https://org.crm.dynamics.com; Username=user@org.onmicrosoft.com; Password=password;"/>
</connectionStrings>

 C#

using Microsoft.Xrm.Client;
using Microsoft.Xrm.Client.Services;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CrmSampleCodes
{
public class QueryByAttributeSample
{
IOrganizationService _service;
public QueryByAttributeSample()
{
_service = new OrganizationService("connection");
}

public void Run()
{
// Create query using QueryByAttribute.
QueryByAttribute querybyattribute = new QueryByAttribute("account");
querybyattribute.ColumnSet = new ColumnSet("name", "address1_city", "emailaddress1");

// Attribute to query.
querybyattribute.Attributes.AddRange("address1_city");

// Value of queried attribute to return.
querybyattribute.Values.AddRange("Redmond");

// Query passed to service proxy.
EntityCollection retrieved = _service.RetrieveMultiple(querybyattribute);

System.Console.WriteLine("Query Using QueryByAttribute");
System.Console.WriteLine("===============================");

// Iterate through returned collection.
foreach (var c in retrieved.Entities)
{
System.Console.WriteLine("Name: " + c.Attributes["name"]);

if (c.Attributes.Contains("address1_city"))
System.Console.WriteLine("Address: " + c.Attributes["address1_city"]);

if (c.Attributes.Contains("emailaddress1"))
System.Console.WriteLine("E-mail: " + c.Attributes["emailaddress1"]);
}
System.Console.WriteLine("===============================");

}
}
}

Color Grid for Dynamics 365

Color Form for Dynamics 365