Feeds:
Posts
Comments

Archive for November, 2008

<script>
function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split(“&”);
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split(“=”);
    if (pair[0] == variable) {
      return pair[1];
    }
  }
}
</script>

<script>
  alert( getQueryVariable(“QueryString”) );
</script>

Read Full Post »

iframe 100% height

So <iframe height="100%"> doesn’t make an iframe fill all the remaining portion of a window like you might expect. I found several places where people showed how they got it to resize with javascript, but those didn’t work for me. The DOM properties that they used were frequently the “page” height (e.g. 250px for a short content page, 1300px for a tall page that has scrolling) or something else wrong. Here is what works for me (in Firefox 2 and IE 7) to make an iframe be as high as possible without causing the main window to have scrolling:

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”&gt;
<html>
<head>Test Page</head>
<body>
<h1>Check out the cool page below</h1>
<p><a href=”/”>Go back home</a></p>

<iframe id=”frame” src=”http://google.com/&#8221; width=”100%” frameborder=”0″ marginheight=”0″ marginwidth=”0″></iframe>
<script type=”text/javascript”>
function resizeIframe() {
    var height = document.documentElement.clientHeight;
    height -= document.getElementById(‘frame’).offsetTop;
   
    // not sure how to get this dynamically
    height -= 20; /* whatever you set your body bottom margin/padding to be */
   
    document.getElementById(‘frame’).style.height = height +”px”;
   
};
document.getElementById(‘frame’).onload = resizeIframe;
window.onresize = resizeIframe;
</script>

Read Full Post »

First off, I want to give a big thank you to Jeremy Winchell for writing up the post that got me started in the right direction for this solution.

For those of you that customize Microsoft Dynamics CRM 4.0, like I do, then likely one of the things you repeatedly run into is clients and users that need to have better names for their actions.  Changing these names on the main navigation page relatively simple, but what about on all the other pages, like Contacts, Accounts, etc.?  These, for whatever reason Microsoft had, aren’t removable or changeable.  It’s a really painful oversight to have to tell a client that even though you have renamed “Products” to “Hardware”, they’re going to have to remember that it’s still going to be “Products” in a few places.  Hopefully the next version of CRM will have the capability to alter and remove these natively, but until then, we’ll have to roll our own.

 Warning, the following actions are not supported or even documented by Microsoft.  Use at your own risk.

Now that the disclaimer is out of the way, let’s take a look at the meat of the solution.  First, go to the customization area of the Entity you want to change, and open its form view.  In there, click Form Properties and enable JavaScript for the OnLoad action.  The link above has pictures if you’re not sure how to get there.

Now you will need the JavaScript:
document.getElementById(“%variableName%”).style.display = “none”

So in this line, %variableName% is the variable related to the button on the left-hand nav.  “none” will hide this element entirely.  (Also, make sure if you copy and paste that you don’t end up with retarded Word-style quotes.  That happened to me and I spent 10 minutes trying to find a typo in my code)

If you want to change the display name of a button, then you have a bit more work to do.

Again, the JavaScript:
document.getElementById(“%variableName%”).innerHTML= “<img src=\”%imageLocation%\” /> %displayName%”;

Here, you will see that we’re using innerHTML to actually change the content of that button.  Now you don’t have to have the image code in here, but if you leave it out, then your link won’t have an image anymore, and will just be text.  If you want to keep the image, the best thing I have found is to use the IE Dev Toolbar and then look at that button’s properties (to get the IE Dev toolbar on a popup screen, hit Ctrl+N).  You will see the link to the default image there.  This is going to be different for every CRM install, so I have not included it on the table below. Then just change the Display Name with whatever you want the button to actually say, and you’re set!  Note that the quotes around the image location have to be escaped.

Below is a list of the links, their variable names, and their default Title.  From there, making changes to the left nav of any entity in CRM should be simple.   You will see repeats of some.  The reason for that is because MS was not 100% internally consistent in its naming scheme.  For example, Cases is IDed by both navService and navCases, depending on where you are.  For those, I would either try both, or check on the screen itself.

Link

Link ID Name

Default Title

Activities

navActivities

View Activities

Campaign Activities

navCampaignActivities

View Campaign Activities

Campaign Responses

navCampaignResponses

View Campaign Responses

Campaigns

navCampaignsInSFA

View Campaigns

Campaigns

navCampaignsInList

View Campaigns

Cases

navService

View Cases

Cases

navCases

View Cases

Competitors

navComp

View Competitors

Competitors

navComps

View Competitors

Contacts

navContacts

View Contacts

Contacts Excluded

navBulkOperationFailures

View Contacts Excluded

Contacts Selected

navTargetedMembers

View Contacts Selected

Contract Lines

navContractLines

View Contract Lines

Contracts

navContracts

View Contracts

Documents

navDoc

View Documents

E-mail Messages Created

navBulkOperationSuccesses

View E-mail Messages Created

Existing Products

navExistingProducts

View Existing Products

History

navActivityHistory

View History

Information

navInfo

View general information about this record

Invoices

navInvoices

View Invoices

Marketing List Members

navListMember

View Marketing List Members

Marketing Lists

navListsInSFA

View Marketing Lists

More Addresses

navAddresses

More Addresses

Opportunities

navOpps

View Opportunities

Orders

navOrders

View Orders

Other Contacts

navContacts

View Other Contacts

Planning Tasks

navTasks

View Planning Tasks

Price List Items

navPrices

View Price List Items

Products

navProducts

View Products

Quick Campaigns

navMiniCampaignsForList

View QuickCampaigns

Quotes

navQuotes

View Quotes

Related Campaigns

navCampaigns

View Related Campaigns

Relationships

navRelationship

View Relationships

Sales Literature

navCollaterals

View Sales Literature

Sales Literature

navSalesLit

View Sales Literature

Sub-Accounts

navSubAct

View Sub-Accounts

Sub-Contacts

navSubContacts

View Sub-Contacts

Substitutes

navSubs

View Substitutes

Target Marketing Lists

navTargetLists

View Target Marketing Lists

Target Products

navTargetProducts

View Target Products

Workflows

navAsyncOperations

View Workflows

Write-In Products

navWriteInProducts

View Write-In Products

 

So now you should have all the tools you need to customize the Entity Screens into something useful for your clients and users.  And don’t forget, if you break something, you can always just delete the JavaScript and start over.

Read Full Post »

Here’s a very quick overview of how to debug your OnLoad, OnSave and OnChange event scripts:

Open the Internet Explorer settings and select the Advanced tab. In the list of available options find the “Disable Script Debugging (Internet Explorer)” setting and make sure it’s unchecked.

Open any script you want to debug and place the following just before the statement where you want to start your debugging session:

debugger
That’s all, no semicolon, nothing else. To test it, run your form from the designer (preview mode) or publish it first. Once the script engine reaches the debugger statement, a list with all available debuggers is presented to you, including the Microsoft Script Debugger, Visual Studio 2003, Visual Studio 2005 or whatever is registered as a script debugger on your machine. You should try all debuggers to find the one you’re most comfortable with and mark it as the default.

Like any other statement, you can simply comment out the debugger statement, so
//debugger

will actually turn off debugging.

All users that have not unchecked the “Disable debugging” setting in IE will not be prompted to start a debugger. However, you should make sure that you remove these statements before publishing them to a production environment. The easiest way to ensure it is to export all customizations and search the export xml file for “debugger”.

 

Read Full Post »

In no particular order, here are the top ten things I’ve learned to pay attention to when dealing with production ASP.NET applications.  Hopefully they will help you save you some time and headaches.  As always, your thoughts and additions are welcome.

1.  Generate new encryption keys

When moving an application to production for the first time it is a good idea to generate new encryption keys.  This includes the machine validation key and decryption key as well as any other custom keys your application may be using.  There is an article on CodeProject that talks about generating machineKeys specifically that should be helpful with this.

2.  Encrypt sensitive sections of your web.config

This includes both the connection string and machine key sections.  See Scott Guthrie’s post for some good references.  Note that if your application runs in a clustered environment you will need to share a custom key using the RSA provider as described in an MSDN article.

3.  Use trusted SQL connections

Both Barry Dorrans and Alex Chang have articles which discuss this in detail.

4.  Set retail=”true” in your machine.config

    <configuration>
    <system.web>
    <deployment retail=“true”/>
    </system.web>
    </configuration>This will kill three birds with one stone.  It will force the ‘debug’ flag in the web.config to be false,  it will disable page output tracing, and  it will force the custom error page to be shown to remote users rather than the actual exception or error message.  For more information you can read Scott Guthrie’s post or the MSDN reference.

5.  Create a new application pool for your site

When setting up your new site for the first time do not share an existing application pool.  Create a new application pool which will be used by only by the new web application.

6.  Set the memory limit for your application pool

When creating the application pool, specifically set the memory limit rather than the time limit which is set by default.  Asp.net has a good whitepaper which explains the value of this:

By default IIS 6.0 does not set a limit on the amount of memory that IIS is allowed to use. ASP.NET’s Cache feature relies on a limitation of memory so the Cache can proactively remove unused items from memory.

It is recommended that you configure the memory recycling feature of IIS 6.0.

7.  Create and appropriately use an app_Offline.htm file

There are many benefits to using this file.  It provides an easy way to take your application offline in a somewhat user friendly way (you can at least have a pretty explanation) while fixing critical issues or pushing a major update.  It also forces an application restart in case you forget to do this for a deployment.  Once again, ScottGu is the best source for more information on this.

8.  Develop a repeatable deployment process and automate it

It is way too easy to make mistakes when deploying any type of software.  This is especially the case with software that uses configuration files that may be different between the development, staging, or production environments.  I would argue that the process you come up with is not nearly as important as it being easily repeatable and automated.  You can fine tune the process as needed, but you don’t want a simple typo to bring a site down.

9.  Build and reference release versions of all assemblies

In addition to making sure ASP.NET is not configured in debug mode, also make sure that your assemblies are not debug assemblies.  There are of course exceptions if you are trying to solve a unique issue in your production environment … but in most cases you should always deploy with release builds for all assemblies.

10.  Load test

This goes without saying.  Inevitably, good load testing will uncover threading and memory issues not otherwise considered.

Read Full Post »

We will use an ActiveX Object from the Scripting.FileSystemObject library to read and write files from JavaScript, which knows how to handle files. The parameter of the OpenTextFile function can be (read = 1, write = 2, append = 8).And here are the scripts:

Reading a File:

function ReadFile()
{

var FileOpener = new ActiveXObject(”Scripting.FileSystemObject”);
var FilePointer = FileOpener.OpenTextFile(”C:\\siva.txt”, 1, true);
FileContents = FilePointer.ReadAll(); // we can use FilePointer.ReadAll() to read all the lines
alert(FileContents);
FilePointer.Close();
}
Writing to File:

function WriteFile
{

var FileOpener = new ActiveXObject(”Scripting.FileSystemObject”);
var FilePointer = FileOpener.OpenTextFile(”C:\\siva.txt”, 8, true);
FilePointer.WriteLine(”I m a good boy”);
FilePointer.Close();
}

Note:
Go to Tools >> Internet Options >> Security, add page to Trusted sites >> then go to Custom level… and look for Initialize and script ActiveX controls. Enable it and restart the Internet Explorer.

Read Full Post »

Entity relationships of MS CRM 4.0

1. One-to-Many System-System (1:n)In CRM 4.0 you can link system entity to another system entity. The child system entity has a lookup field to associate it with a parent system entity.

 

2. Self-Referential

In CRM 4.0 you can link An entity to itself. For example a Case can be linked to a master Case.

3. Multiple Relationships Between Entities

Many of you know about mulitple lookups issues with same entity, now it can be achieved in MS CRM 4.0 e.g the Account entity might have two relationships with a Contact entity – a primary and secondary Contact.

4. Many-to-Many System-System, System-Custom & Custom-Custom (n:n)

In CRM 4.0 this is major requirement for many to many relationship, now it is possible . Not only will this remove the need to build a “joining” entity, but you have control over how the relationships show up in the UI.

Read Full Post »

You can increase size of attachment in MS CRM. by default it is 5mb.

1. Open the web.config of MS CRM

2. Locate httpRuntime the key within the element and change the values to the following:

httpRuntime executionTimeout=”9999″ maxRequestLength=”10240″

3. Locate httpRuntime the key within the element of the element, and change it to the following:

httpRuntime maxRequestLength=”10240″

save the web.config and restart IIS.

Regards,
Siva

Read Full Post »

Did you know you can save a record by pressing ALT + S on the keyboard? There are many convenient keyboard shortcuts that you can use to speed up your work. Keyboard shortcuts can even be more ergonomic than using your mouse in some cases. In addition to common shortcuts, such as CTRL+C to copy and CTRL+V to paste, here are 10 keyboard shortcuts you may find useful.

Top 10 keyboard shortcuts
To do this Press

Select all text in the current field or current list

CTRL+A

Close an active form

ALT+F4

Move forward through a form’s fields

TAB

Move backward through a form’s fields

SHIFT+TAB

Save a form

CTRL+S or SHIFT+F12

Save and close a form

ALT + S

Expand/collapse Form Assistant

CTRL+SHIFT+F

Cancel edits and close a form

ESCAPE

Delete a record

CTRL+D

Save and then open a new form

CTRL+SHIFT+S

For more keyboard shortcuts, search the Microsoft CRM online Help for “keyboard shortcuts.”

You can also use keyboard shortcuts to zip around the Microsoft CRM client for Outlook folders in Microsoft Office Outlook. Although there are no shortcuts available that are specific to Microsoft CRM client for Outlook, here are the top ten Outlook shortcuts that I find useful.

Top 10 Outlook keyboard shortcuts
To do this Press

Switch to Mail

CTRL+1

Switch to Inbox

CTRL+SHIFT+I

Switch to Outlook Calendar

CTRL+2

Switch to Outlook Contacts

CTRL+3

Switch to Outlook Tasks

CTRL+4

Display the Address Book

CTRL+SHIFT+B

Create a new Appointment

CTRL+SHIFT+A

Create a new Contact

CTRL+SHIFT+C

Create a new Task

CTRL+SHIFT+K

Check Spelling

F7

For more Outlook shortcuts, in the Type question for Help box, type “Outlook keyboard shortcuts”.

The shortcut keys described here refer to the U.S. keyboard layout. Keys on other layouts might not correspond exactly to the keys on a U.S. keyboard.

Read Full Post »