Tuesday, April 19, 2011

Passing the CRM_URL from Parent Record to Drill-Down records

Part 1:

I think most of us know that the CRM_URL parameter in the report allows us to open the CRM record directly from the reports. For those of you who do not know this, you can probably refer to this link: Using CRM_URL Report Parameter

Part 2:

The above feature will work if you are trying to open the CRM record from any main report. In my scenario, I had a main report called 'Contact Category'. Clicking on any category will drill down to another report called 'Contact Details'.  Now, when the user clicks on a particular contact's name, I wanted to open the respective CRM contact record. 
When I tried the steps in the above link, it did not work for me. On further investigation I found that, when we drill-down from a main report into a child report, the child report is opened within the context of the main report i.e. the URL displayed in the address bar will be of the main report and not of the child report. 
As a result, the report does not recognize the parameters that are declared in the child report. 

To resolve this issue, we need to pass the CRM_URL parameter from the main report to any of the child or drill-down reports. To do this, 
a. Create a new "Hidden"  report parameter called CRM_URL in the parent report.
b. Select "Allow null value" and "Allow Blank Value".
c. Now, navigate to the report properties where you specify which drill-down report to navigate to (In SSRS 2008, its Report Properties-->Action-->Go to Report-->Child report)
d. Add a new parameter that needs to be passed to the child report.
e. Select CRM_URL from under the "Name" drop down list
f. Type "=Parameters!CRM_URL.Value" for the value and click on OK.
g. Perform the steps specified in the above link for the child report.

Save and upload your reports. Now, every time you drill down to the child report, the CRM_URL parameter also gets passed from the parent report as a result, allowing you to open the respective CRM record.

Thats it!

Tuesday, April 5, 2011

Resizing the IFRAME in Header in CRM 2011

I was trying to add an IFRAME in the header in CRM form with a height of just 1 row. For some reason. CRM would not respect the 1 row height in the header. It would display about 6 rows always. This was very strange but after posting in the CRM Dev Forum (http://social.microsoft.com/Forums/en-US/crmdevelopment/thread/da61999c-d5e3-45a9-841c-3e09a84782d4/), it was confirmed that this seems to be a bug.
As a workaround, you an try the following code:
document.getElementById('IFRAME_Name').style.height = 35;

OR
document.getElementById("IFRAME_Test_d").parentElement.parentElement.height = 35;
Update - This issue seems to have been resolved with the Update Rollup 1 for MS CRM 2011

Friday, April 1, 2011

Making Notes non-editable after X hours

Recently, there was a requirement from my client that they wanted to ensure that the notes for all the entities be made non-editable after 8 hours from the time the note was created for a specific set of users with say "Salesperson" role.
After some thinking, I came up with the below idea.

1. I gave the "Salesperson" role only User level Write access on the Note entity.
2. Then I created the below workflow on the Note entity :


3. For demo purposes, I wait for only 1 minute after a note is created but you make it wait for as long as you need.
4. As you can see above, I check if the created by is someone other than Administrator. I then wait for a minute and then update the owner of the Note to Administrator.
5. Since a Salesperson has only User level Write access, when he tries to edit this note, he will get an error saying that he does not have sufficient privileges.

Cheers,
Srihari

Thursday, March 31, 2011

Getting started with writing JScript in MS CRM 2011: Step by Step

We are just in the process on migrating to 2011 and I was just trying to write some JScripts for testing purposes. However, I found that the way of writing JScript in 2011 has changed a bit and after some trying, the below are the steps that I used to write my JScripts:

1. I created a simple JScript function as shown below in Visual Studio:
function welcome() {

    alert("Welcome to CRM 2011");
}
BTW, it looks like all the JScript in 2011 can only be accessed using functions.
2. Save this file as TestWebResource.js
3. Open CRM and go to your custom entity's customization and click on Form Properties
4. Under Form Libraries -->Click on "Add"
5. In the Look Up Record, click on the "New" Button
6. In the "Web Resource: New" window, fill the mandatory fields and then click on "Browse" -->select the JScript file that we  had saved earlier and open. Save this file(I also published it).
7. Select OK in the "Look Up Record" window
8. You should be back at the main "Form Properties" window as shown below:

9. Now, click the "Add" button under Event Handlers for the onLoad event.
10. The library will default to our jscript file. Type "welcome" as the function name and click on OK
11. Save and Publish.
12. Click on Preview-->Create Form
13. You should see the alert being displayed:

Thanks!

Friday, March 18, 2011

Error while Importing a solution in CRM 2011 - The solution file is invalid. The compressed file must contain the following files at its root: solution.xml, customizations.xml, and [Content_Types].xml

I was trying to add a button to the ribbon but I was not able to test it as I would keep getting the below error while trying to import the solution zip files:

























After spending a huge amount of time checking and rechecking my code, I was finally sure that the issue had to be somewhere else.
Finally, it turned out that when I used to zip the folder using the built in windows compression(zip), it would create a folder inside the zip file and place the solution files inside this folder.

So, as the error above states, CRM is looking for those files in the "Root" but was actually finding a folder in it's place and hence throwing the error. When I selected the solution files and zippped them directly, the import was successful. I know this might be a small thing but it definitely cost me an awful lot of time. :)

Thursday, March 17, 2011

Wednesday, March 16, 2011

Invalid column name 'DeletionStateCode' CRM 2011 upgrade

I was getting the error "Invalid column name 'DeletionStateCode'" when I was trying to upgrade from 4.0 to 2011. After a lot of trials and errors I got to know that there were many stored procedures and triggers in the database which were referencing to this column. 


Since the 'DeletionStateCode' has been dropped in 2011, maybe it was erroring out while trying to upgrade them.


Solution: I deleted all the triggers and stored procs from the database as it was just a test environment and I was able to install 2011 sucessfully.