Thursday 17 September 2015

How to retrieve data from multiple entities in CRM

I have an entity called "A" and it has two lookup fields to entities "B" and "C". Now I want to retrieve data from all the three entities using CRM SDK.


  1. QueryExpression query = new QueryExpression("EntityALogicalName");
  2. query.ColumnSet = new ColumnSet("column1", "coumn2");
  3. // Or retrieve All Columns
  4. //query.ColumnSet = new ColumnSet(true);
  5.  
  6. LinkEntity EntityB = new LinkEntity("EntityALogicalName", "EntityBLogicalName", "EntityALinkAttributeName", "EntityBLinkAttributeName", JoinOperator.Inner);
  7. EntityB.Columns = new ColumnSet("column1", "coumn2");
  8. EntityB.EntityAlias = "EntityB";
  9. // Can put condition like this to any Linked entity
  10. // EntityB.LinkCriteria.Conditions.Add(new ConditionExpression("statuscode", ConditionOperator.Equal, 1));
  11. query.LinkEntities.Add(EntityB);
  12.  
  13. // Join Operator can be change if there is chance of Null values in the Lookup. Use Left Outer join
  14. LinkEntity EntityC = new LinkEntity("EntityALogicalName", "EntityCLogicalName", "EntityALinkAttributeName", "EntityCLinkAttributeName", JoinOperator.Inner);
  15. EntityC.Columns = new ColumnSet("column1", "coumn2");
  16. EntityC.Columns = new ColumnSet("column1", "coumn2");
  17. EntityC.EntityAlias = "EntityC";
  18. query.LinkEntities.Add(EntityC);
  19.  
  20. query.Criteria.Conditions.Add(new ConditionExpression("status", ConditionOperator.Equal, 1));
  21.  
  22. var result = service.RetrieveMultiple(query);
  23.  
  24. foreach (var entity in result.Entities)
  25. {
  26. // Get the Columns from the Entity Obj Like this. Depands on type of the Column.
  27. string entityAColumn1 = entity.Contains("column1") ? entity["column1"].ToString() : string.Empty;
  28. // Use Link Entity Alias with column name
  29. string entityBColumn1 = entity.Contains("EntityB.column1") ? (entity["EntityB.column1"] as AliasedValue).Value.ToString() : string.Empty;
  30. string entityCColumn1 = entity.Contains("EntityC.column1") ? (entity["EntityC.column1"] as AliasedValue).Value.ToString() : string.Empty;
  31. }

 You can use Left Outer join if there is possibility that any lookup values can be Null. You can access the Link Attribute using LinkEntity Alias mention in code. I hope this will also work.

The below Url might give more information and syntax for linked entites 
http://congruentdynamics.blogspot.co.uk/2013/05/retrieve-linked-entity-data-using-query.html

https://lakshmanindian.wordpress.com/2012/11/30/retrieve-data-using-fetchxml-with-multiple-link-entities-in-crm-2011/

Micrsoft Dynamics CRM 2011 online - Retrieve Plugin

Retrieve
If  you want to write a plugin that executes every time a user opens a record.

Here is the Retrieve Code

First, create a new Plugin and sign the assembly with a key:



public void Execute(IServiceProvider serviceProvider)
{
    // Obtain the execution context from the service provider.
    Microsoft.Xrm.Sdk.IPluginExecutionContext context = (Microsoft.Xrm.Sdk.IPluginExecutionContext)
        serviceProvider.GetService(typeof(Microsoft.Xrm.Sdk.IPluginExecutionContext));

    if (context.Depth == 1)
    {
        IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
        IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

        // Obtain the target entity from the input parmameters.
        EntityReference entity = (EntityReference)context.InputParameters["Target"];

        ColumnSet cols = new ColumnSet(
                             new String[] { "lastname", "firstname", "address1_name" });

        var contact = service.Retrieve("contact", entity.Id, cols);

        if (contact != null)
        {
            if (contact.Attributes.Contains("address1_name") == false)
            {
                Random rndgen = new Random();
                contact.Attributes.Add("address1_name", "first time value: " + rndgen.Next().ToString());
            }
            else
            {
                contact["address1_name"] = "i already exist";
            }
            service.Update(contact);
        }
    }
}


Next, got to the Plugin Registration Tool (included with the CRM SDK) and register the plugin as follows:

image

What you’ll end up with in this example is:
On first open of the record:
clip_image002
On all future opens of the record:
clip_image002[5]


Tuesday 15 September 2015

Clean AsyncOperationBase table

MS CRM IS SLOW THEN FOLLOW THESE STEPS AS FOLLOW:

Hi There,
Highly recommend to clean table AsyncOperationBase for performance issue.
http://support.microsoft.com/kb/968520

this script clean the table and improve Async operations.
thanks,
Happy CRMing

Sunday 13 September 2015

HOW TO FIND A RECORD WITH "GUID" IN CRM 4.0

Find the Record using Guid in crm 4.0

Recently i faced a situation where i need to find a record with its GUID.
The reason is CRM  Opening some of the PDF's (form to PDF) And CRM is failing to open some of the record's PDF.

So i have checked the Log File where i have seen GUID of the failed Record's GUID.

To find out the Failed record in crm is bit pain, so here is the following solution as follows:  

Here is a quick solution to find a record using its GUID.

Go to the Entity records and open one of the record

Press F11  and it maximize the window 

Here you will see the record GUID in the URL and replace the GUID of the record you want to find out and browser again, then you will find the record you are looking for.

The following URL's might give more information


To find out the record GUID without any coding here is the URL




Wednesday 9 September 2015

CREATE A SHORTCUT FOR POWERSHELL ON DESKTOP

CREATE A SHORTCUT FOR POWERSHELL ON DESKTOP

PowerShell-logo-128x84
There are some really helpful scripts out there. Not just for Lync and Exchange. But many other apps and administrative tasks. Sometimes, however, the people who need to run them aren’t well versed in PowerShell. This makes is cumbersome for them to open PowerShell, navigate to a folder containing a script, and execute it with the correct parameters. This often leads to complaints about the difficulty of the process, or those admins just not using that tool. As not all admins have our PowerShell prowess, we can create a desktop shortcut that will allow an admin to simply double-click on it to execute it. Let’s see an example.
For this example, I’m going to use Johan Veldhuis’ very slick sefautil GUI, a wrapper for the Lync sefautil.exe program. Sefautil is a resource kit utility that allows an admin to set things like delegates, call forwarding, and other settings, on behalf of users. Sefautil has some really painful syntax, and a complete lack of error reporting. Using it is often frustrating. Johan’s GUI for it makes life SO much easier, that I found myself using it a LOT.
Let’s say, for the sake of this example, that the script, called sefautil_gui.ps1, is in a folder called c:\_scripts. When you execute Johan’s script, you must pass it a front end pool name using the “-pool” parameter. Normally running it would require something like the following:
.\sefautil_gui.ps1 -pool pool01.contoso.com
With a shortcut, we need to tell it to launch PowerShell, and call the script along with the parameters. The syntax is the full path to powershell.exe, along with the “-command” parameter and the syntax used for the script. The syntax is wrapped in quotes, and prefixed with an ampersand. PowerShell resides at C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
  1. Right click on the desktop, and choose New>Shortcut.
  2. Enter a path for the shortcut. For our example, we’ll use
    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command “& c:\_scripts\sefautil_gui.ps1 -pool pool01.contoso.com”
  3. Click Next.
  4. Give the shortcut a name. We’ll call it “sefautil GUI”. Then click Finish.
Let’s set the starting path. Right click on the newly created shortcut, and click Properties. Click on the Shortcut tab. In the “Start In” field, let’s set it to “C:\windows\system32\WindowsPowerShell\v1.0”.
You may have noticed that the shortcut has the PowerShell icon. While that’s all fine and damn sexy, we might want to change that. That’s simple enough since we’re already on the Shortcut tab, click the Change Icon at the bottom and choose whichever icon you’d like. For mine, I chose the Deployment Wizard icon. This is available by browsing to %ProgramFiles%\Microsoft Lync Server 2013\Deployment and choosing Bootstrapper.exe.
While Johan’s script is a GUI based script, many are not. If that’s the case, we can tweak the session settings a little further. On the Options tab of the shortcut, you can tailor settings like Quick Edit mode, which makes selecting, copying, and pasting easier. Obviously, the Font, Layout, and other tabs provide further control over the experience.
Also note that non-GUI scripts will close the PowerShell window when they are done running, so a script might need to be tweaked to pause before closing. YMMV.
Once you’re done, click Ok. U See..
sefautil GUI shortcut
Now, simply double clicking on our new shortcut launches the script.
sefautil GUI

I often do this for many 3rd party administrative tools, including Lync Call Pickup Group Manager,Lync RGS Holiday Set EditorCentralized Logging Tool, and more.

LEARN POWERSHELL FROM THE BELOW URL

MS Dynamics CRM 2011 Ribbon Customization

Sunday 6 September 2015

Migrating from CRM 4.0 to CRM 2011 OnPremise step by step

Here is the step by step migration process for CRM 4.0 to CRM 2011 OnPremise


There are 2 ways you can do a migration from Microsoft CRM 4.0 to Microsoft CRM 2011 on-premise:   an in-place migration where you upgrade the existing CRM 4.0 install to CRM 2011 using the very same server(s) OR an upgrade where you migrate to a new CRM 2011 server(s).
 
If you have the available server hardware, the 2nd approach is probably best.   With this approach, the existing production server running CRM 4.0 is not changed.   So if your migration goes bad, you haven't affected the production environment. Also, keep in mind that since CRM 2011 requires the latest Microsoft technologies (Windows Server 2008, SQL Server 2008) a lot of people are forced to migrate to new servers anyways.
 
Here is a step by step guide to migrating using this 2nd approach (where you have new server(s) that will host CRM 2011):
 
1.   Perform a fresh install of Microsoft CRM 2011 on a new server(s).   You can have 1 server that hosts both the web application and the SQL databases or you can have 2 servers:   1 to host the web application and 1 to host the SQL databases.
 
NOTE1:   Attached is a zip file that contains the Microsoft CRM 2011 implementation guide in compiled help format.
 
NOTE2:   Ideally, when you create an organization, use a name that does not match your current organization.    When you eventually import your current organization, you won't be able to re-use the same organization name if the new organization name you create right now matches your old name.    So use a name like "Test company" or "new company".
 
2.   Make a backup using SQL Server Management Studio of your existing CRM 4.0 sql organization database (it will have a name like OrganizationName_MSCRM).
 
3.   Physically copy the backup from step 2 to your new server that will be hosting the SQL Server 2008 databases behind your CRM 2011 install.
 
4.   Create a new sql server database on your new server hosting the SQL Server 2008 databases for CRM 2011 using SQL Server Management Studio.   You can give it any database name.
 
5.   Restore the backup from step 2  over your new sql server database from step 4.
 
6.   Open the CRM 2011 Deployment Manager software that is running on your new machine that is running the CRM 2011 web application.   Click on the Import Organization Wizard.  
 
FYI:   this Microsoft website has good screenshots of this step:    http://technet.microsoft.com/en-us/library/hh127042.aspx
 
7.   In CRM 2011 Deployment Manager, notice that you now have 2 organizations.
 
The URLs of these 2 organizations are slightly different based on the name:
 
http://server/NewOrganization/main.aspx       (original test organization)
 
http://server/RealOrganization/main.aspx       (the production organization you just converted)
 
You can disable the new organization in CRM 2011 Deployment Manager.
 
8.   If you just type in http://server in your browser, your browser will re-direct you to one of these 2 organizations.    If you have disabled the "new organization" you may even get an error message when you type http://server/ into the browser as it will try to re-direct you to a "default organization" that you have disable.
 
9.   Each CRM user has a "default organization".    See the article for discussion of this issue.
 
 
10.   Were there any add-ons to CRM 4.0 installed?   Normally, Microsoft's guidance says to remove them from CRM 4.0 before you migrate the data to CRM 2011.    But that's a bad idea if your trying to do the CRM 2011 conversion without touching your production CRM 4.0 box.   This website has some thoughts:
 
    
 

Saturday 5 September 2015

A free customizable Editable Grid for Dynamics CRM 2013/2015

Using DIFFINDAYS to auto calculate age of a contact – Dynamics CRM 2015 Online Update 1

Using DIFFINDAYS to auto calculate age of a contact – Dynamics CRM 2015 Online Update 1


CRM 2015 Online - Accessing Subgrid data using Javascript

CRM 2013/2015 HTML Editor / Rich Text

Thursday 3 September 2015

Some Useful Microsoft Dynamics CRM


These are some of the useful urls

http://blogs.infinite-x.net/2009/06/30/free-utility-released-export-javascript-from-crm/







http://www.xrmcoaches.com/developertraining/extending/

=============================================

http://blogs.msdn.com/b/crminthefield/archive/2012/03/12/microsoft-dynamics-crm-2011-white-papers-amp-technical-documentation.aspx

http://www.infinite-x.net/resources/

https://andz88.wordpress.com/2014/05/06/data-migrationsystem-integration-using-ssis-salesforce-to-dynamics-crm-example/



Top 25 dynamic crm sites

====================================================================================



Microsoft Dynamic crm 2013 onpremises installation on virtualbox

Hi There,

This post will help many Microsoft dynamic crm developer who are in early stage of their carrer,
Here is the links to follow, how to install Microsoft Dynamic CRM 2013 Installation on VirtualBox.

1) First Download the VirtualBox and Install it on Windows 10

2) Download the Windows Server 2008 iso file on windows 10

3) Then select the Windows Server 2008 iso  and install on virtualbox, Hmm, you are progressing.
a) Select the Hard disk of more than 30 GB
b) RAM around 4 GB, depends upon the host computer.

4) After successful configuration of the windows server on virtualbox

5) Download the SQL Server 2008 R2 on to the windows server  and install.

6) Reporting services Manager download  and install on virtualbox

http://blogs.msdn.com/b/niran_belliappa/archive/2013/11/05/step-by-step-installing-dynamics-crm-2013-on-windows-server-2012.aspx



ms dynamics crm 2013 installation on virtualbox:




7) Download the Microsoft Dynamic CRM 2013 server setup file and run on the Virtualbox.

8) Each time installing the software please pay extra care while installing.



visual studio download link

Hi There,

Please find the link to download the visual studio:

http://www.unlockwindows.com/download-visual-studio-2012-rc/

Microsoft Visual Studio 2010 Ultimate Product Key
YCFHQ9DWCYDKV88T2TMHG7BHP
Visual Studio 2010 Professional
YCFHQ-9DWCY-DKV88-T2TMH-G7BHP OR YCFHQ 9DWCY DKV88 T2TMH G7BHP
Visual Studio 2012 Ultimate
RBCXF-CVBGR-382MK-DFHJ4-C69G8
Visual Studio 2012 professional
4D974-9QX42-9Y43G-YJ7JG-JDYBP
Visual Studio 2013 Ultimate
BWG7X-J98B3-W34RT-33B3R-JVYW9