Monday, 10 September 2012

Filtered CRM LookUp Fields in style

 
 

Backround:

I had a crazy requirement on how the lookup value need to be selected, this included a lot of business rules and filtering. I chose to go the custom page route, two fields which are looksups and are dependant on each other. Financial Year determines the values for Business Unit

Details:
I used a custom aspx page that accepts Financial Year ID and Business Unit ID from the crm form- lookup fields hidden on the form. if the Ids are recieved then this is an exisiting record then i set the values on my custom page to wat is recieved from query string. I also read values that could be selected depending on the business rules. for axample only future financial years could be selected.

If querystring is empty I then just fill my dropdown with possible values. If the financial year is seleccted I fill in my business Unit dropdown with treeview that is built to easily allow the user to select the right Business Unit they belong to/want to work with. I then put the lookup image next to the treeview-embeded dropdown so that a user can click to pop open the actual crm entity we are looking up. the highlighted rows on the screenshop above is my custom page in an IFrame.  these controls are Telerik controls.

I then read the values from the iframeon the onsave event,

var fycontrol = crmForm.all.IFRAME_FY.contentWindow.document.getElementsByName("hfSelectedFYId")[0];
var bucontrol = crmForm.all.IFRAME_FY.contentWindow.document.getElementsByName("hfSelectedBU")[0];

I check if these are set. if not I cancel the saving event as these two fields are Business Required.

Happy Coding!

Friday, 18 May 2012

Moving CRM Organization from one environment to another

Hi Friends,

This is a step-by-step process to successfully moving your CRM Organization from one invironment to another. This also includes errors that are likely to occur:


1. Bakup your Organization_MSCRM database on old environment - In sql right click the database - Tasks - BackUp

2. Install a clean CRM on your new environment with a Temporary organisation - this will be ditched later

2. Restore the Database backed-up in step 1 on the new environment - In Sql right click the Database folder -  Restore Database - In database enter the original name of the database you backedup in step one, select from file - click ... to browse to the .bak file you got from step 1

3. Now Open Deployment Manager - on Organization folder - right click- Import. Click Yes to confirm the pop up

4. Enter the database server name of the new environment

5. Select the Database you restored (you moved from the old environment)

(Are you on the same domain or NOT)

if you are on the same domain, continue and make sure the users are mapped properly - If not the same then map them manually - BEST thing is to only map the setup administrator users only - the rest can be done later

6. Click next to create - this takes some time depending on the size of your database

 Should you get the error :

An error occurs when importing an organization in Microsoft Dynamics CRM 4.0 “ExecuteNonQuery requires an open and available Connection. The connection's current state is closed.”

Solution: follow these steps  and come back and try again from step 3.

7. The Organization has been imported.

8. Open Crm :

Should you get the error :

"ExecuteNonQuery requires the command to have a transaction when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized"

one or both of the two fixes might help:

 Go to SQL

 8.1 Setup default organization for all users by runing the two sql queries

Use MSCRM_CONFIG

SELECT Id, UniqueName FROM Organization

Copy the Guid of the organization you just imported [newOrgGuid]

Use MSCRM_CONFIG

UPDATE SystemUser
SET DefaultOrganizationId = [newOrgGuid]



__________________

try Step 8 again:

Should you get the error :

"ExecuteNonQuery requires the command to have a transaction when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized"

then Go to SQL still

Go to Security

go to NETWORK\SERVICE

GOTO UserMapping

Select the new Organization Database

Make sure NETWORK\SERVICE is the db_owner



Continue with step 8.

If issues are still found share with me!







Monday, 7 May 2012

Restore deleted records in crm

I deleted by mistake some records on crm on my personal practise crm 4.0.

I then logged on to the database blah_MSCRM

and ran my sql query

SELECT * FROM
Account

where deletionstatecode=2
_____________________________________

update Account

set deletionstatecode= 0 --this will make your records to be deactivated but showing in crm

where deletionstatecode = 2

an error occurred when the workflow was being created. try to save the workflow again

So I got this Error after adding my custom activity to my workflow and tried publishing:

An error occurred when the workflow was being created. Try to save the workflow again.


I tried everything:

Roll ups and editing web.config but no help. My other Workflows worked fine, to me that meant my new custom workflow is up to shebert...


Please check:

My class and namespace was SendEmailActivity :

Changing my Namespace to XXXX.SendEmailActivity

This fixed it:

Not sure if it was because the two (nmsp and class) are the same or because Starndard CRM clushes with these.

Name things properly


Tuesday, 24 April 2012

CRM 2011 hiding one related link from entity left nav "Documents", "Campaign"

This Javascript hides one related link

function hideNavItem(navItem) {
     Xrm.Page.ui.navigation.items.forEach(function (item, index) {
         var itemLabel = item.getLabel();
         if (itemLabel == navItem) {
             item.setVisible(false);
         }
     });
 }

hideNavItem("Relationships");


You can hide Activities by:

hideNavItem("Activities");

Crm 2011 hiding Sales. Markerting, Common Nav Group in Entity left nav

This javascript hides the Sales Nav Group under Related left nav on CRM 2011 Entity

//Hides Nav Group inside a crm 2011 enitity

function hideNavGroup(navigationName) {
    var navItems = document.getElementById("crmFormNavSubareas");
    for (i = 0; i < navItems.childNodes.length; i++) {
        var navItem = navItems.childNodes.item(i);
       var itemName = navItem.firstChild.lastChild.innerText;
        if (itemName == navigationName ) {
   navItem.style.display = "none"
        }
    }
}

Consumption:

hideNavGroup("Sales");

The Sales group is removed,


You Can hide Service by:

hideNavGroup("Services");



Friday, 20 April 2012

To follow : Telerik Controls + Ajax + Crm 2011 + SharePoint 2010

This is to follow soon with screenshots

Tools: CRM Entity Comparer -EntityComparer

I have had to write a tool that will compare same entity on two environments - long story cut short - there are multiple environments which are not really supposed to be the same  but branch off one same environment - Diff client - Diff Requirements, same solution - This means importing customizations is not an option - if you have money for multiple servers to monitor all, good for you

This works on All Dynamics CRM versions - this means you can copy attributes from entity 1 of crm 2011  to entity1 of crm 3.0/4.0

This also works on different domains - option of using same credentials for both environments or two different sets

You also have the option to create the attribute or leave it out







- This will be shared on codeplex soon
- Link To folow Or request on kgopotso.riba@gmail.com

Andriod Apps using C# + Visual Studio

I recently picked up a habit of building Android Application using C# and Visual Studio as I an quiet comfortable with the language and IDE

I use Mono for Android plugin : read more: http://xamarin.com/monoforandroid

It has been really fun I must say, so much planned around, will also be integrating the android app I am building with CRM 2011

Quick things to share:

The GUI is build through an Xml markup called AXML - this is andriod's version of  xaml (Xaml is a markup used on Microsoft's WPF, Silverlight and Windows Phone 7(Mango) GUIs)

Android Controls are called Views

e.g

Android Textbox = EditView
Android Label = TextView
Button = Button
Spinner = Dropdownbox

For example this AXML


below produces a UI like the one below



And Yes the Code is C# - it uses a WCF Service call to login the user 



This is fun, I might be uploading this on Code Project - just look and listen






IE + Developer toolbar not pop open

I tried pressing F12 while I was working on CRM 2011 via IE8, nothing happend, but i can see the developer toolbar icon on my task bar, Do this to fix:

1. Open Task Manager
2. On the Developer Toolbar application- Right Click Maximize
3. Now you can drag the window to your task manager to, it will minimize it, but this time to where you can see it!

Stupid but true, it was just minimized and its off the screen

Thursday, 12 April 2012

Static IPs on VM, NAT - no connection to host for copying files

Am I crazy or someone is also going through this


Problem:

I set my VM to be NAT Network Adapter
I am using static IPs because I set up a small network between VMs
Dooof: I cant connect to my  host- I need to copy over files

Solution:

Temporarily change the Lan Properties to get IP Automatically - this will break the ntwork with the VMs - small network - but fix connection to the host network

Copy the files using a network path

after copying,

Take back Static Network

If there is a better way of doing this, please share

Network between 2 VMs not working - same config

Problem:

I have been using two VMs for my CRM Environment, VM1 has CRM and VM2 has domain controller, but VM1 cannot see VM2 despite having the same network config, same subment mask, ips are in the same range.

What I had to do:

VM1 was using NAT on Network Adapter
VM2 was using Bridged on Network Adapter

Solution:

Make sure both VMs are using the same config on network adapter:

I used Host Only on both network adapters. It worked

Wednesday, 11 April 2012

CRM 4.0 Javascript to CRM 2011

http://crm2011scriptconvert.codeplex.com/releases/view/52074

Upgrade Crm 4.0 to 2011

I went through this once upon a time:

http://community.dynamics.com/product/crm/crmtechnical/b/crminogic/archive/2011/01/04/crm-4-to-crm-2011-upgrade.aspx

I recently did an Inplace Upgrade, but that is because of lack of resources, if it wasnt for that, I would go for full crm install then do an upgrade via importing organization db:

Please make sure you login to the server with an account that has access to the crm 4.0 you are attempting to upgrade and:

Sandbox Service runs under an account that has access to CRM - this service imports all your plugins to the new crm 2011