Thursday, June 16, 2011

how to import only stored procedures in sql server


While migrating from MS CRM 4.0 to MS CRM 2011, if your 4.0 contains some custom SPs,
before migrating you need to 1st chop all there, then import by using the deployment manager.

After that you can again put back the SPs.
So if the number is too high(for me it was around 250) :(
then just follow the below
Below steps may help you. Finally you will get output in scripts. Execute that script in your destination.

Before that make sure to back up your destination DB.
Hope this will help others also.

No more DeletionStateCode in ms crm 2011

we all know better that there was a "DeletionStateCode" in MS CRM 4.0, while writting stored procs else any custom scripts or any query to get only the live records.
The technique in 4.0 was a soft delete and then an asyn service will run to do the permanent delete.
But in 2011 it has been changed to hard delete, so if any one is deleting from UI it will be a permanent delete, so "DeletionStateCode" here.
If anyone has written any Stored Procs or any query which is related to this attribute "DeletionStateCode", then while migrating they need to be careful about it.

Hope this will help others.

Wednesday, June 15, 2011

Plug in Registration Tool for MS CRM 2011

Please down load the solution(source code) from download here for plugin registration tool.
Build it only using the Visual Studio 2010(a big restriction by MS).
then run the exe file and then as usual , but a bit difference in the tool.
if any one does not have VS studio, can contact me, i can share the builded exe files ;)
Sudhanshu

Tuesday, June 14, 2011

Control the height of header of the Form in ms crm 2011

there is a big thing in ms crm 2011, that the header is getting bigger(may be rows 6), if am putting any iframe into it, even if i have tried to squize the height of the iframe and also the source page for it.

So what i did is just write a line of JS code onload of the form.
Just try to get the id of the image on top of the form for that entity
and put the following code.
I did it for Contact.
document.getElementById('ico_fhe_2').parentNode.style.height = "70px";
Just you need to change the Id as per the image present in the Entity form corner.
This you can get easily by using the IE developer tool.

There is another found, if the entity is custom and u are changing the image, then there may be chances of missing the id,
in that case if you are using the IFRAME then take the id of IFRAME and use the below code
document.getElementById('IFRAME_name').style.height = "80px";
Hope it helps.

Monday, June 13, 2011

to find the SPs and delete

while migrating from ms crm 4.0 to 2011 , i was trying to import the DB i have taken after restoring.
The issues i have faced was the Cutom SPs and the Functions and Triggers are created by the 4.0 team.
1st need to clean them
to clean the SPs, we need to find them out, we can get some in the follwoing query unless untill the developers ahve given the proper names.
select 'Drop Procedure ' + name from sys.procedures Where [type] = 'P' and is_ms_shipped = 0 and [name] not like 'sp[_]%diagram%' -- this is CRM SP names
and name like '%' --SP name STD is the starting name your team has used

now copy and run the result from the above command.

to clean the Triggers we need to find them out, we can get them in the following query

SELECT S2.[name] TableName, 'drop trigger ' + S1.[name] TriggerName,
CASE WHEN S1.deltrig > 0 THEN 'Delete' WHEN S1.instrig > 0
THEN 'Insert' WHEN S1.updtrig > 0 THEN 'Update' END 'TriggerType'
FROM sysobjects S1 JOIN sysobjects S2 ON S1.parent_obj = S2.[id] WHERE S1.xtype='TR'

now copy the whole 2nd column and run it from the result of the above query.


Putting Custom Pages in Ms crm 2011

while puting custom pages under ISV in MS CRM 2011,(even if its recomended as using silver light pages), but while migrating from 4.0 to 2011, we may need the custom pages as it is, if we have more number of custom pages.

Once we will deply the normal application, suddely we will get the following error
.

So to resolve all these things we need to add the following dlls to the bin folder of your custom application else in GAC
1.Microsoft.Crm.dll
2.Microsoft.Crm.Sdk.dll
3.Microsoft.Crm.Platform.Sdk.dll
4.AntiXssLibrary.dll
all the abive dlls u can find from your bin folder of the CRM installed.

this is what i have faced.

Sudhanshu


Could not load file or assembly 'Microsoft.Crm, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

Sunday, June 12, 2011

Linking Common JS file (External JS file) in ms crm 2011

We all have experience of reusing codes.
same also happnes in JS codes using.
In ms crm 4.0 we can do it
link1
and Link 2

But in MS CRM 2011, we can do it in more easy way as the Web resource Concept.
Just create a webresource as the external JS file.

1. Suppose i have a test entity. so on the onload of the test, we can write
function _onload(){
alert("hello world!!! inside test entity");
//now call the function of the external js, which has been loaded as webresource
externalCall();
}
2. now the External.js file will be like
function externalCall(){
alert("Inside External JS file");
}
3. here we have to add the External.js in the Form properties of Test entity as well.
4. Now add the event handler of onload of the form to the _onload function

here you go.

Wednesday, June 8, 2011

MS CRM 2011 hide the left nav, still provide superb hyperlink called soft link to all the tabs

Hi All,

1st of all it may be unsupported but will do a magic.
Sometimes we need more space in the form and we do't want to show the left nav options to the uses, unfortunately we loose the hyperlinks to the section(tab) in the form at the same time.
In MS CRM 2011 , it has been given fantastically, just a checked, unchecked and u are done to show and hide the left nav pan.


Here we can take the advantage of the Header(another brilliant feature by MS CRM 2011 team).
1. create an HTML page with the hyperlinks u want.
2. include that as an Iframe in the header
3. Now create iframes in each sections(tabs) of the form, with rows 1 and do not show any level, border. If u have IFRAMES already, then no need to create in each sections(tabs). Just put the frames in the beginning of the Sections(Tabs).
4. create a blank html page with the same looks and feels as the crm form and include in the above IFRAME source
5. Now in the hTML page in step 1 for header, you just need to put some code as folllows
suppose i have 4 IFrames in four Sections(Tabs) named as IFRAME_Test1,2,3,4
so the html page will be something like this

#. if you have different tabs added abd you want to focus, else to different sections, you can avoid the step 3 and 4, just get the tab id or section id by using the IE developer tool and create <a> tags in HTML page as below and pass the IDs to the JS function.

<html>
<head>
<script>
function _focusSection(_id){
parent.document.getElementById(_id).focus();
}
</script>
</head>
<body aLink=#0000ff link=#0000ff bgColor=#eeeeee vLink=#0000ff>
<a href="#" onclick = "return _focusSection('IFRAME_Test1');">Test Hyperlink1</a>
<a href="#" onclick = "return _focusSection('IFRAME_Test2');">Test Hyperlink2</a>
<a href="#" onclick = "return _focusSection('IFRAME_Test3');">Test Hyperlink3</a>
<a href="#" onclick = "return _focusSection('IFRAME_Test4');">Test Hyperlink4</a>
</body>
</html>

in above the hyperlinks also can be placed by styled buttons or images etc.. which looks like tabs...
just try it, and seeee....

Tuesday, June 7, 2011

how to do alternate colors of records in the grid in ms crm 2011

Sometimes the requirement used to come as the records in the main grid to be alternate colors as in normal grid controls.
keep it in mind we are going to alter the aspx page provided by MS CRM :P
To achieve it in CRM just needs some JS code.

1. open the HomePage.aspx from the _root folder
2. append a method onload of the body as <body class="stage" onload="alterGridRecords()">
3. now the function alterGridRecords should be as followed

function alterGridRecords(){
var grid = document.getElementById("gridBodyTable").lastChild; //gridBodyTable is the id, wch will help
for (var i = 0; i < grid.childNodes.length; i++)
{
if ((i % 2) == 0) {
grid.childNodes[i].style.backgroundColor = "#EEEEEE"; //put color as per the user requested
grid.childNodes[i].colourised = true;
}
else {
grid.childNodes[i].style.backgroundColor = "#FFFFFF"; //put color as per the user requested
grid.childNodes[i].colourised = true;
}
}
}

this is so simple

there is simple prob, as if u will select the records the colors will not be changed to the selected color.
So make the alternate colors to the 1st column only as it it colored only one color in ms crm 2011.
grid.childNodes[i].childNodes[2].style.backgroundColor = "#FFFFFF";

thats it. even if the 1st column will not be colored when selected, other columns will be colored where as the 1st column can make the altered colors :P

have fun. ;)

URL has been changed in MS CRM 2011

The url we used to use in MS CRM 4.0 for opening a record or opening the balnk window for any new record has been changed in MS CRM 2011.
In MS CRM 2011 it uses some encodes in the url.
URL in MS CRM 4.0 is
. http://<ip>:<port_no>/<Org_Name>/sfa/conts/edit.aspx?id={GUID}# for default entities
. http://<ip>:<port_no>/<Org_Name>/userdefined/edit.aspx?id={19B8CEA8-95CB-DF11-84AB-E41F132DDD8E}&etc=10051# for custom entities

the URL format in MS CRM 2011 is something like
http<s>://<ip>:<port_no>/<Org_Name>/main.aspx?etc=1&extraqs%3f_gridType%3d1%26etc%3d1%26id%3d<guid>%26rskey%3d<some number>&pagetype=entityrecord

So while migrating this need to checked all thru out the JS code or if any custome applications also in ISV blah, blah blah...

The spl characters in the URL defines as follows

Character Escape Code
SPACE----%20----
<----%3C---- >----%3E----
#----%23----
%----%25----
{----%7B----
}----%7D----
|----%7C----
\----%5C----
^----%5E----
~----%7E----
[----%5B----
]----%5D----
`----%60----
;----%3B----
/----%2F----
?----%3F----
:----%3A----
@----%40----
=----%3D----
&----%26----
$----%24----

hope this helps