June 26, 2013

XRM: Bind a CRM Option Set to a DropDownList


This Method bind a CRM option set to a DropDown List ( The Option Set would reference a field in a specific entity )

 public static void fillOptionsList(IOrganizationService service, string EntityLogicalName,
          string fieldName, DropDownList optionSetList)
        {
            try
            {

                RetrieveAttributeRequest retrieveAttributeRequest =
                    new RetrieveAttributeRequest
                    {
                        EntityLogicalName = EntityLogicalName,
                        LogicalName = fieldName,
                        RetrieveAsIfPublished = true,
                    };

                // Execute the request.
                RetrieveAttributeResponse retrieveAttributeResponse =
                    (RetrieveAttributeResponse)service.Execute(
                    retrieveAttributeRequest);

                // Access the retrieved attribute.
                PicklistAttributeMetadata retrievedPicklistAttributeMetadata =
                    (PicklistAttributeMetadata)
                    retrieveAttributeResponse.AttributeMetadata;

                // Get the current options list for the retrieved attribute.
                OptionMetadata[] optionList =
                    retrievedPicklistAttributeMetadata.OptionSet.Options.ToArray();

                //Dictionary<int,string> LocalizedLabelDic = new Dictionary<int,string>();

                //List<ListItem> OptionSetItems = new List<ListItem>();

                foreach (OptionMetadata o in optionList)
                {
                    optionSetList.Items.Add
                        (new ListItem(o.Label.LocalizedLabels.FirstOrDefault().Label, o.Value.Value.ToString()));
                }
            }
            catch (Exception e)
            {
                //Logger.LogException(e);
            }
        }

Exporting Single Entities using CRMSvcUtil tool

In the last days while working on a CRM customization project that interacts with SharePoint web parts, while refactoring the code, I thought of trying to minimize the size of the file generated originally by the CRMSvcUtil by only choosing the needed entities in my solution. The generated file was almost 5MB in size which is a very big load to the system, but apparently in CRM SDK 2011 microsoft removed the parameter called Entity to specify specific entities. Then I searched the web and found this great post that give a perfect, simple, and working solution for this issue 

http://erikpool.blogspot.com/2011/03/filtering-generated-entities-with.html

April 22, 2013

CRM Error - Invalid Action: Solved


While working on an MSCRM project I encountered the following error all over the site and I could do nothing 

I checked MSCRM services in Services.msc and found the Asynchronus Processing Service stopped


I started it and all is fine again !

April 04, 2013



Installation of CRM 2011 on windows 2012 AND SQL 2012:



Hardware:
·         Virtual Machine >> 6 GB
·         Virtual Machine >> 4 GB
Software:
·         First VM: 
o   Windows Server 2012
o   SQL Server 2012
o   SSRS Reporting Service

·         Second VM: CRM
o   Windows Server 2012





Main Issues Encountered:

Issue 1:     

·         Tried to install CRM, Installer didn’t start Normally
o   It started then disappeared
o   After checking the task manager, it was running as a background operation but actually not taking any memory so it was only residing in the background
·         After Research, and referring to some blogs, the installer won’t start since some files in System32 folder in windows 2012 are different from those in 2008 R2, and others are not found
·         Then
o   I took a backup of the following file : svrmgrnc.dll
o   Deleted It from System32
o   And took the same file from a windows server 2008 R2 machine and pasted it in the same folder
o   Also I added 3 other needed files taken from the 2008 R2 machine which are not found in windows server 2012. Those files were the following:
§  Microsoft.Windows.ServerManager.dll
§  rmConfigHelper.dll
§  ServerManagerCmd.exe
NA: The reason for using those files is, Microsoft Dynamics CRM 2011 installation program uses a deprecated command line tool called ServerManagerCmd.exe to install and manage Windows features during the installation. ServerManagerCmd.exe depends on a few other libraries including rmConfigHelper.dll, svrmgrnc.dll, and Microsoft.Windows.ServerManager.dll.

This issue is understood from the following post by Daniel Craig

·         I started the installation and then it started normally





Issue 2 & 3:

·         During the installation there is this stage were we need to add the users for CRM service accounts
·         ·         At this stage, I added all the users “by the book” 

  • As I continued the installation :
    • I encountered an error (issue 2) that stated the database was not valid in the last step before the installation starts.
    • After research through technet posts I needed to download two roll-Ups for CRM 2011 (Roll-Up 6 and Roll-Up 12) and I could then pass that last validation.
    • But as the installation started, it did hit an unidentified Error(issue 3, which I didn’t document) but after some trial in order to solve this error, It turned up to be that I need to use the Network Service Account for all the services although it is not supported
    • So I restarted the installation which completed as before but during the Installation
    • At the beginning this error will appear, but the installation will continue

    •  Then, during installation, two errors were shown, those errors were related to Windows Indexing Service which is no longer available for Windows Server 2012 and these are screen shots









      • The Installation Ended with the following screen shot


        • NA: This screen shot was taken after SSRS was installed on the CRM server (So this is a second trial of installation), but the same screen was shown.
  • Although the Installation was completed with those errors, I couldn’t actually open the CRM site, it always showed a 404 page not found
    • I am not sure if I needed any other step, but I didn’t have more time to search to solve this issue. But It could use some more research



Issue 4 and 5:

·         Even that the site wasn’t working, I was trying to install the SSRS connector on the server to see if it had any effect on the site, during installation the installer couldn’t locate the Report Server Instance(Issue 4)
·         So I installed the SSRS as a feature on the same CRM Server
·         Then I tried to start a new Installation for the connector which directly crashed with an error that It couldn’t install one of its pre-requisites (Issue 5)
o   I tried to download updates, there wasn’t.
o   After research it turned out the SQL uses a new C++ Redistributable version - 10.0.40219 – while CRM2011 uses Redistributable - 10.0.30319, so I Un-Installed the redistributable version 10.0.40219 and the start the installation
o   The Installer could find the new SSRS instance, but at the last step, which is the verification step it showed a validation issue on the Database.

This was the point where I stopped the work. I believe some more research can be done to make this possible.
NA: Microsoft will have a new release for CRM2011 during Q2 of this year which hopefully will solve all of these issues.

Thank You.



Cannot Deploy Solution to SharePoint: Solved


Recently, while I was working on a SharePoint project, specifically on creating a custom web-part, so the VM  I was working on was old enough, and having a lot of issues ( I use it for testing ), and while deploying the solution the deployment stopped with an error that deployment of the solution have failed.
After investigation I found out that the "SharePoint 2010 Administration" service was stopped, I tried to start the service but that action would always fail. since I needed to test my solution I used the following command to actually deploy the solution again


stsadm.exe -o execadmsvcjobs 

what it did was it executed all the administrative jobs, and as one of the, deployment.

Good Luck !

Installation of CRM 2011 on windows 2008 R2 AND SQL 2012



Installation of CRM 2011 on windows 2008 R2 AND SQL 2012:



Hardware:

·         Virtual Machine >> 6 GB
·         Virtual Machine >> 4 GB

Software:

·         First VM: SQL + DC
o   Windows Server 2012
o   SQL Server 2012
o   SSRS Reporting Service

·         Second VM: CRM
o   Windows Server 2008 R2

I started by Installing SP1 for server 2008 R2, then I installed CRM2011, No issues showed up, also the users for services were added as per the book, the Installation was completed successfully. Then I installed Roll-Ups 6 and 12 since both are needed for compatibility with SQL 2012.

Issue 1:

·         The site was working normally, I was trying to install the SSRS connector, and during installation the installer couldn’t locate the Report Server Instance.
·         So I installed the SSRS as a feature on the same CRM Server connecting to the already installed SSRS report server on the SQL machine, without creating a new instance.
·         Then I tried to start a new Installation for the connector, It could locate the report server instance normally and the installation was successful.
      NA: You should install SSRS connector on the server where SQL is installed, and make sure that your CRM installation files are the latest, and downloading latest updates.


March 14, 2013

Best practices in MS-CRM Installation: Service Accounts

MSCRM Service Accounts:

I am installing MS-CRM on a server running windows server 2008 R2, and another server hosting the SQL2012 running on windows server 2012 

during the installation of CRM2011, this screen will appear 


Now I will show how to succeed in adding valid accounts : 
NA: you dont have to stick to the naming below, but Always  give clear names
  1. CRM Application Service Account
    • Name: CRMAppSvcAcc
    • Add to Performance Log Users group
    • Add to  local Administrators group
  2. CRM Deployment Web Service Account
    • Name: CRMDeploySvcAcc
    • Add to Performance Log Users group
    • Add to  local Administrators group
  3. CRM Sandbox Processing Service Account
    • Name: CRMSandboxSvcAcc
    • Add to Performance Log Users group
  4. CRM Asynchronous Processing Service Account
    • Name: CRMAsyncSvcAcc
    • Add to Performance Log Users group

If you are using a Server for MS-CRM and a Server for MS-SQL then make sure to add the users to groups on both servers, else you will see this error



Good Luck :)
I am ready for any questions

March 13, 2013

Create a Custom Action on a SharePoint List\Library


Custom Action:

This custom action is used to start a specific deletion workflow 

1-      Open main site in SharePoint designer



2-      Go to lists and libraries










3-      Choose the preferred library






4-      Click New Custom action as List Item Menu






5-      Add the action name




6-      Choose “Initiate Workflow”




7-      Choose the preferred workflow ex: “Delete an item”




8-      Click Ok

March 11, 2013

SharePoint PowerShell Useful Commands


SharePoint Power-Shell Useful Commands

Adding a solution :

  • stsadm –o addsolution –name SharePointProject2.wsp

or Using SharePoint Management Shell :

  • Add-SPSolution c:\code\SharePointProject2\bin\debug\SharePointProject2.wsp



Deploy a solution :

  • stsadm –o deploysolution –name SharePointProject2.wsp –url http://moss-server –allowCasPolicies –immediate

or Using SharePoint Management Shell :

  • Install-SPSolution –Identity SharePointProject2.wsp –WebApplication http://sp2010 -GACDeployment

March 08, 2013

Getting User Profile information in a mixed authenticated web application (Claims Based)


If you ever needed to get user information, in a claims based authenticated web application (mixed authentication), by using the web service method: GetUserProfileByName in InfoPath, (actually, it’s the only method you can use, because all the other possible ways, and even the managed code behind in InfoPath, they all work in the client mode, but never on the browser!!!!!! since querying user profiles directly, in a mixed authenticated web app isn’t possible!! it always give you the “unauthorized” error logged whenever u try to run in from the browser!)
So, here’s what you gotta do:

1.       You have to have a web application with Classic mode authentication only in your farm, suppose this is its url: http://sp:4444/  
2.       Create a new Data Connection Library in the site that hosts your InfoPath form (it’s a type of SharePoint library that stores connection files, with a .udcx extension: these files are usually used for cross-domain data connections.)
3.       In your InfoPath form, Add a “Receiving Data” connection – From a SOAP service – point it to the url of the user profiles service, in the Classic authenticated web application (e.g.: http://sp:4444/_vti_bin/UserProfileService.asmx), name it: GetUserProfileByName.
4.       In the same Data Connections wizard, select the data connection:  GetUserProfileByName, and click on : “Convert to connection file”, and type-in the url of your data connection library, and give a name for your data connection file (e.g.: http://sp:2012/DataConnectionLibrary/GetUserProfileByName.udcx)
5.       Go to the DataConnectionLibrary to make sure the new connection file has been added, download a copy of It, and edit it to add/update the following tag:
<udc:Authentication>
                <udc:UseExplicit CredentialType="NTLM">
                <udc:UserId>domain\adminUserName</udc:UserId>
                <udc:Password>password</udc:Password>
                </udc:UseExplicit>
</udc:Authentication>
6.       Add the updated .udcx file back to the data connections library, then click on the arrow next to the item’s Name to Approve it.

Now your data connection to the User Profiles service is ready to be used in the form, both on the client form and the browser form!

NB: This experience was taken from my colleague Malek El Zeeni