My Photo

Microsoft Dynamics 365

Official Blog for Microsoft Dynamics Functional and Technical Solutions....
Browsing Category " MSCRM 2011 "

Create Your First Plugin Dynamics MS CRM

For your first Plugin we will take a test scenario - on create of contact record our plugin will forcefully update its email address to "testemail@gmail.com" and to achieve this you just need to follow the below steps.

There are two parts to successfully run a plugin in MSCRM

1) Create Your Plugin
2) Resister your plugin

Plugin Creation

Step 1 - Open Visual studio


Step 2 - Go to File - New - and Click on Project


Step 3 - A dialogue will appear, from left navigation panel select Class Library template in Visual C#  and Enter Project and Solution name and hit on OK Button


Step 4 - Visual studio will create and open a blank class library template.Right Click on Project and click on Add References option


Step 5 - Reference Manager dialogue will open.From left navigation panel go to Assemblies - Framework then select two references and click on OK button
1)System.Runtime.Serialization
2) System.ServiceModel


Step 6 -  Right Click on Project and again click on Add References option, then in Reference Manager dialogue from left navigation panel go to Browse - Click on Browse button then select two references
1)System.Runtime.Serialization
2) System.ServiceModel



Step 7 -  After Click on Browse button go to your sdk (downloaded from prerequisites) - bin, then select the following dlls files and click on add and then OK button
1) miscrosoft.xrm.client.dll
2) Microsoft.Xrm.Sdk.dll


Step 8 -  Open the class named Class.cs from solution explorer and modify the below code in it.
If your namespace name and class name is different then remember to verify and update it.

Code Snippet : 


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

namespace My_First_Plugin
{
    public class Class1 : IPlugin     //{inherit the class Iplugin in your class}
    {
        public void Execute(IServiceProvider serviceProvider)        //{add the execute method}
        {
            // create context , service factory and service objects
            IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(Microsoft.Xrm.Sdk.IPluginExecutionContext));
            IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
            IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

            //to enter  value in Email field in contact entity

            //create an object of predefined class Entity and pass entity name as its parameter
            
            Entity Object = new Entity("contact");   // in place of contact you can write schema name of entity on which you want to preform operations

            Object.Attributes.Add("emailaddress1", "testemail@gmail.com");  //emailaddress1 is the schema name of the Email field in contact entity
             //testemail@gmail.com is the value

            //to update the record service.Update(object of the entity)
            service.Update(Object);

        }
    }
}

After updating your code your code will look like this 


Step 9 -  Right click on Project and click on Properties


Step 10 -  Now, we have to create a key. Go to Signing - select the checkbox "Sign the assembly" and click on <New..> option 


Step 11 -  Enter any name you want for your Key and click on OK button


Step 12 -  Click on Save Button


Step 13 - Go to BUILD from ribbon menu and select Build Solution option




Will Update this thread Soon 


Happy Coding 😊


StringMap table in MS CRM

 String Map table in dynamics crm that what is the benefit of table in reporting and how can we use this?
So what is string map table actually means in CRM?
String map table used in MSCRM for storing the details of Option Set Fields exists in an organization .It contains all the data (Attribute Name, OptionSet name, option value , option name) of option set
Below is the structure of StringMap table:

Beginning JavaScript ms CRM 2011

Xrm.Page.context Methods

1. getAuthenticationHeader: 
Returns the encoded SOAP header necessary to use MSCRM 4.0 Web service calls.
2. getCurrentTheme:
Returns the current Outlook theme chosen by the user.
3.getOrgLcid:
Returns the LCID value for the base language of the organization.

How to Create Dynamic OptionSet in MS Dynamics CRM 2011 & 2013 dynamics365

How to Create Dynamic OptionSet in MS Dynamics CRM 2011 & 2013


This code will help you..................

function dynamicoptionset() {

//get value in no in variable
    var totaldivision = Xrm.Page.getAttribute("fieldname" ).getValue();
    if (totaldivision == null || totaldivision == "" )
        return;
    else {

Upgrade MSCRM

  • Upgrade MSCRM:-
Click here to download:-    MSCRM Upgrade 2011 to 2013

  1. First of all go to the Programs and Features using Control panel and Uninstall  Microsoft Dynamic CRM 2011 Reporting Extensions.
  2. Go to MSCRM Setup and double click on setupserver.exe and get all the latest updates.
  3. Give MSCRM  2013 product key.
  4. Select “<None>” and click on next. Notice that any organization not upgraded , will become disabled after the upgrade is complete. To upgrade organizations, use Deployment Manager. Click Next to upgrade Microsoft Dynamics CRM.

Get Form Type And Save Modes using JavaScript in mscrm 2011 , mscrm 2013 , mscrm 2015


getSaveMode() : Its Return a value telling what was the save event of ms crm entity record ( like is it due to deactivation of form , manual save or save and close etc) below is the full list of events .

// Code
execObj.getEventArgs().getSaveMode();


Event ModeValue
Save1
Save and Close2
Deactivate5
Reactivate6
Send (Email)7
Disqualify (Lead)15
Qualify (Lead)16
Assign (user or team owned entities)47
Save as Completed (Activities)58
Save and New59
AutoSave70
getFormType() :  Its Return a value Telling about form type of ms crm entity record ( Update , or create etc) , below is the full list of events.

Get Difference in days between two date fields using javascript ( differences between dates )

Hello , below you will find function calculating difference in days between two field using java script .

function diffrenceindays() {
    var startdate = GetDateValue(startfield);
    var Enddate = GetDateValue(endfield);

    var oneday = 1000 * 60 * 60 * 24;
    var differenceInDays = ((Enddate - startdate) / oneday);
    if (differenceInDays < 0) {
        alert(" date cannot be less then start date");

    }
    alert(" diffrence in days  " + differenceInDays);

}

function GetDateValue(field) {


    var year = field.getFullYear();
    var month = field.getMonth();
    var day = field.getDate();
    dateOnly = new Date(year, month, day);
    return dateOnly;


}





SOURCE : JUST2CODE.IN Subscribe to our YouTube channel : https://www.youtube.com/user/TheRussell2012

Activate / Deactivate a record using c# in MS CRM 2011 , MS CRM 2013 , MS CRM 2015 ( using SetStateRequest )


hey , as we offensively get requirement to activate and reactivate a record then we start using update event , but there is a very simple method to do so , by using SetStateRequest : it require an assembly " microsoft.crm.sdk.proxy.dll " and using " using Microsoft.Crm.Sdk.Messages;" .
Code will be :
   SetStateRequest req = new SetStateRequest();
             //the entity you want to change the state of
   req.EntityMoniker = new EntityReference("new_abc", recordId);
            //what should the new state be
    req.State = new OptionSetValue(1);
           //Pick an option from the status reason picklist to specify reason for state change
    req.Status = new OptionSetValue(2);
    SetStateResponse resp = (SetStateResponse)service.Execute(req);

Fields that are not valid were specified for the entity - Importing Solution Error mscrm 2011 , mscrm 2013 , mscrm 2015

Hey , I was importing a solution today from an other Organization and got a Error new to me :  Fields that are not valid were specified for the entity , as there was no description i was little confused , but after few R&D came up with perfect resolution of the error .

Reason 

  • Organization "A" conatined attribute 'new_mscrm' that was of type "single line" ,Later  We changed that the field  to be an currency Type.
  • But in Organization "B" was containg same field 'new_mscrm' of type "Single line".
  • When we tried to import back the new solution to test environment we got this Import failure

Get field Name Using JavaScript in ms crm 2011 , ms crm 2013 , ms crm 2015 ( get dynamically field Label using JavaScript)



Hi all below you will find how to get field label name using JavaScript .

 var fieldname = executionContext.getEventSource().getName();
NOTE: Remember to pass context as perimeter while submitting function Name.



SOURCE : JUST2CODE.IN Subscribe to our YouTube channel : https://www.youtube.com/user/TheRussell2012

microsoft dynamic crm certification Exam Name and links, Type of Certification By Microsoft For Microsoft Dynamics Crm 2011 , 2013 , 2015 ( Certificate Name and Code )

Share A Record With Read Only Access Using Custom Workflow IN MS CRM 2011 , MS CRM 2013 , MS CRM 2015

Share a Record to a user without Assigning the record and with out giving Read access to that user , its a Custom Workflow to share a record with read only access , ( NOTE : You can not give read only access to owner of that record so , first we have to change the owner and then we can share it to created by user with read only access )



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Portal;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Messages;
using Microsoft.Xrm.Sdk.Workflow;
using System.Activities;
using Microsoft.Crm.Sdk.Messages;


namespace Readonlyaccess_sharerecord
{
    public class Class1 : CodeActivity
    {
        #region input parameter

RELATIONSHIP ( 1:N , N:1 , N:N ) IN MS CRM 2011 , MS CMR 2013 ( TYPE OF BEHAVIORS ) WITH EXAMPLES


Hello , In todays blog i am gonna show you how relationship works in mscrm works . Below we will go through a set of screen shots of examples.Relationship plays an important role in ms crm , There are 3 type of Relationship in Microsoft dynamic crm .

  1. ONE TO MANY     ( 1:N ) Relationship
  2. MANY TO ONE     ( N:1 ) Relationship
  3. MANY TO MANY   ( N:N ) Relationship