Formatting postal codes

Working with postal codes is again left to the latitude of developers. With the wide range of countries supported, it would be unrealistic to try to provide the functionality out of the box.

Getting ready

Using the previously created solution or a new solution, we will add postal code formatting for the Account entity.

How to do it...

Take the following steps to format a postal code:

  1. Add a JScript web resource to hold your script.
  2. Add the following script to the resource:
    // Function to format postal code // for both Canadian and US postal codes function FormatPostalCode(context) { var oField = context.getEventSource().getValue(); var sTmp; if(typeof(oField) != "undefined" && oField != null) { // check for US ZIP code if(oField.match(/^[0-9]{5}$/)) ...

Get Microsoft Dynamics CRM 2011 Scripting Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.