I'm always asked about a simple way to format the phone numbers in Dynamics CRM as they're a simple string. There are many options from simple JScript (shown below) that can work online or offline, advanced JScript (using a webservice) which requires the user to be in a connected state, or a pre or post callout which is more advanced and also doesn't provide instant feedback to the end user. The disadvantage of using JScript is it doesn't work with items being imported or through the web services interface where a pre/post callout can be used for this. The perfect solution is to combine the JScript and a pre/post callout to achieve the consistency on all of the ways of entering information within Dynamics CRM.
This article assumes you know how to first backup your information within CRM prior to making any customizations and that you understand how to make changes on a form to the onChange event of a form. In addition, I'm presume that you've made customizations in the past and that you're comfortable doing so. If you're not you're welcome to contact me with your questions and I'll be glad to assist you. The code I'm going to show you is a very basic JScript routine that I created that meets a majority of installation needs and is a great starter piece that can be easily copied and pasted into Dynamics CRM. The code will format as (xxx) xxx-xxxx Ext. xxxx and will default in the area code if the area code wasn't entered (e.g. the length is seven characters in length). You'll want to change the default area code to meet your organizations needs.
--- Begin Snippet ---
// Format phone
numbers
function
fncFormatPhone(sTemp) {
var sDefaultAreaCode
= "574";
sTemp =
sTemp.replace(/[^0-9]/g,""); //remove illegeal characters
sTemp =
sTemp.substr(0, 14); // First 14 digits
if (sTemp.length ==
7) sTemp = "("
+ sDefaultAreaCode + ") " +
sTemp.substr(0, 3) + "-" + sTemp.substr(3, 4);
else if
(sTemp.length == 8) sTemp =
"(" + sTemp.substr(0, 3) + ") " + sTemp.substr(3, 3) +
"-" + sTemp.substr(6, 2);
else if
(sTemp.length == 9) sTemp =
"(" + sTemp.substr(0, 3) + ") " + sTemp.substr(3, 3) +
"-" + sTemp.substr(6, 3);
else if
(sTemp.length == 10) sTemp =
"(" + sTemp.substr(0, 3) + ") " + sTemp.substr(3, 3) +
"-" + sTemp.substr(6, 4);
else if
(sTemp.length == 11) sTemp =
"(" + sTemp.substr(0, 3) + ") " + sTemp.substr(3, 3) +
"-" + sTemp.substr(6, 4) + " ext. 000" + sTemp.substr(10, 1);
else if
(sTemp.length == 12) sTemp =
"(" + sTemp.substr(0, 3) + ") " + sTemp.substr(3, 3) +
"-" + sTemp.substr(6, 4) + " ext. 00" + sTemp.substr(10, 2);
else if
(sTemp.length == 13) sTemp =
"(" + sTemp.substr(0, 3) + ") " + sTemp.substr(3, 3) +
"-" + sTemp.substr(6, 4) + " ext. 0" + sTemp.substr(10, 3);
else if
(sTemp.length == 14) sTemp =
"(" + sTemp.substr(0, 3) + ") " + sTemp.substr(3, 3) +
"-" + sTemp.substr(6, 4) + " ext. " +
sTemp.substr(10, 4);
return sTemp;
}
--- End Snippet ---
The above code will be used every where you want to add the phone code. Below is the step-by-step instructions for adding to the Account form for the main phone number. You will repeat these steps for each of the phone numbers in the system that you want to have this code on. Alternately, you can use scripts similar to the above to determine the format based on the country if the form has one, by the user, by the type of field (phone vs. fax) for example.
- Log into your Microsoft Dynamics CRM system as a user with System Customizer rights
- Click on Settings
- Click on Customization
- Note: Don't forget to Export your customizations BEFORE and AFTER you've done all of these changes so you can revert back if there's a problem.
- Click on Customize Entities
- Double-click on Accounts
- Click on Forms and Views
- Double-click on Form
- Double-click on Main Phone
- Click on Schema and make note of the Schema Name as this is the name you will use to format in a few steps
- Click on Events
- Click on Edit as onChange is the only option you don't need to select this first
- Copy and paste the code from above
- Now for formatting the field you have two choices. The first choice is great as it's a simple copy/paste in the field and can be included in the snippet you copied above. The second is ideal if you're adding the formatting to the onLoad event of the form as you can specify the name of the field you want to format. I use the first one for the individual fields and the second for the onLoad event for this basic script.
- if (event.srcElement.DataValue != null) fncFormatPhone(event.srcElement.DataValue);
- if (crmForm.all.telephone1.DataValue != null) fncFormatPhone(crmForm.all.telephone1.DataValue);
- Now repeat this for every field you have on the form.
That's all there is to it. Now to test before saving and deploying your code.
Testing
Click on the Preview menu bar item and choose Create Form. You will now want enter text into all the fields you've entered and also REMOVE the text to make certain you have no errors within the form.
Saving
If everything is good then click on Save and Close
Deploying
Click Actions and choose Publish.
You're all set and ready to go for this form. Repeat the above steps above for each one of the forms that you want/need this code on. The forms can either be the core forms or the custom entities that you've created.
Additionally, items that code like the above can be used for our zip/postal code look up that fills in the city/state through a web service (or pre/post callout), formatting based on the country selected, validation of email and web addresses, etc. You're only limited by your imagination, budget and time that you have. With that being said remember that sometimes less is more so you need to properly way the balances for the customizations you make to your system.
With any new product there's always compelling new features, bug fixes and reasons that the manufacturer thinks you need to upgrade. But with all the new features what are some of the key benefits that you will gain by utilizing WSS 3.0/MOSS 2007? Below is a list of many items that I've found that help justify doing an upgrade.
-
Only see what you have access to where in previous versions you saw things even if you didn't have access to and given a nice message of "Access denied"
-
Blogs - Blogs provide a publishing-oriented experience for a single user or a team. Windows SharePoint Services 3.0 includes a site template that supports:
- Article posting
- Reader comments
- Archive views
- RSS feed generation
-
Wikis - A wiki is a new site template in Windows SharePoint Services 3.0 that makes it easy to create, edit, link, and restore an individual Web page. Wikis can be used as creative forums to brainstorm ideas, manage knowledge bases, create designs as well as instruction guides or simply gather information in an easy-to-edit format. Wikis are easy to create, modify, and annotate in addition to tracking contributions and changes. Key features include:
- Fast and easy page creation
- Easy and automatic linking
- Version differences
- What you see is what you get (WYSIWYG) Web page editing
Wikis leverage existing SharePoint functionality including search, navigation, alerts, and custom fields.
-
Document Libraries - Improvements to SharePoint document libraries include:
Similar to the functionality provided by public folders in Microsoft Exchange Server, e-mail enabled discussion boards support:
- Checking out documents locally
- Offline document library support in Microsoft Office Outlook 2007
- Major and minor version numbering and tracking
- Support for multiple content types
- Policy, auditing, and workflow
- Tree view support
-
Content Types - Content types are reusable definitions of document types across your organization. A single document library can store content with multiple document types.
A content type is used to define a group of documents that share a common set of attributes; including:
- Document templates
- What’s on the “New” button
- Metadata specific to the content type
- Shared column property templates
- Custom InfoPath forms in 2007 Microsoft Office system applications
- Enterprise defined policies
- Common workflows
Content types are different from traditional file types (which map to physical file formats like Word documents or Excel spreadsheets). Content types are used to define and implement business documents such as functional specifications, budget planning spreadsheets, or new product concept presentation.
-
Windows Workflow - Windows SharePoint Services 3.0 hosts Windows Workflow Foundation (WF) to enable customized creation of workflow solutions and use of structured workflows on document library and list items. Office SharePoint Designer 2007 can be used to design and configure custom workflow solutions with the support for WF in Windows SharePoint Services 3.0.
Ready-to-use workflow templates are available with Office SharePoint Server 2007 as well as a new set of application solutions for Windows SharePoint Services downloadable from the Microsoft TechNet Web site.
-
RSS Feeds - Although this is something that can be added to 2.0 it's straight out of the box and on every part on WSS/MOSS (if the Administrator enables it). Use RSS feeds to syndicate content managed in a portal site.
-
Office 2007 - Windows SharePoint Services 3.0 easily integrates with smart client tools through a set of Web services and documented application interfaces. Users can readily adopt these new tools because of their similarity to other familiar environments, such as the Microsoft Office system. For example, users of 2007 Microsoft Office system programs such as Word, Excel, PowerPoint, InfoPath, Project, and OneNote can directly interact with information stored in SharePoint sites without having to manually download the content. Users can create workspaces, post and edit documents, and assign tasks, all while working on documents stored in SharePoint sites.
-
-
Document workspaces - Create shared attachments to store dynamically created SharePoint document workspaces as well as being sent as a conventional attachment.
-
Meeting workspaces
-
Events (Calendar) (two-way interaction) - Calendars have been enhanced with richer calendar views, expanded support for recurring events, and all-day events.
-
Contacts (two-way interaction)
- Tasks (two-way interaction)
- RSS
- Email Integration - Document libraries, discussion boards, calendars, and announcements can be enabled to receive new postings via e-mail. In addition, extensible support is provided for custom e-mail handlers in Windows SharePoint Services 3.0.
Similar to the functionality provided by public folders in Microsoft Exchange Server, e-mail enabled discussion boards support:
- A highly scalable, topic-based architecture
- New “super rich-text” field type
- Unified experience for both e-mail and Web-based discussions
- One-step creation of Active Directory directory service distribution lists as part of the site creation process
- Unified SharePoint group and Active Directory management functions
- Windows Mobile Support - All SharePoint portal, team site, and list pages now render on international and North American mobile devices (including Web-enabled mobile phones) using a simplified text-only format.
- Enhanced Search
- Features
- Audiences
- Interface
- Top navigation bar
- Development
- Object Model - All object model changes in Windows SharePoint Services 3.0 are highly backward-compatible with Windows SharePoint Services 2.0 SP2. However, you should be aware that your old code, although it will compile, may not behave as expected in the new object-model hierarchy. The Administration object model (Microsoft.SharePoint.Administration) has been completely re-factored to allow for greater extensibility. There is now a hierarchical object store.
- ASP.Net 2.0 - Windows SharePoint Services 3.0 leverages the reliability, scalability, and functionality of ASP.NET version 2.0. This includes support for the ASP.NET version 2.0 Web Part Model (with added backward compatibility support for Windows SharePoint Services 2.0 SP2 Web Parts). Building on ASP.NET not only provides a deep technical foundation for Windows SharePoint Services, but also allows Windows SharePoint Services to leverage the Visual Studio development environment for application development.
- Master Pages - Each Web page in a SharePoint site references an ASP.NET version 2.0 master page. Master pages provide centralized control of the layout and style of all the pages in a SharePoint site. Each site has a master page gallery that the site owner can use to customize the look of all of the pages on the site.
- Web Services - Windows SharePoint Services 3.0 expands several existing Web services, increasing the number of methods provided through the Lists, SiteData, UserGroup, WebPartPagesWebService, and Webs services.
- MOSS Specific
- Business Data Catalog (BDC)
- Excel Services
- Records Repository
- Key Performance Indicators
- PowerPoint Slide Libarries
- My Sites - The My Site personal site gives users an opportunity to aggregate information “for me,” “by me,” and “about me.” Significant enhancements include social networking, privacy controls, SharePoint Sites and Documents Aggregation Web Parts, and Colleagues and Memberships Web Parts.
With WSS 3.0 / MOSS 2007 and Outlook 2007 new features became available but what about users who still use Outlook 2003? What features are still available for them? Below is a simple chart that shows the functions of both.
| SharePoint Version |
Outlook 2003 |
Outlook 2007 |
| WSS 2.0 |
Read-only |
Read-only |
| SPS 2.0 |
Read-only |
Read-only |
| WSS 3.0 |
Read-only |
Two-way |
| MOSS 2007 |
Read-only |
Two-way |
One item to take good measures on is to setup a good and solid backup strategy for your Microsoft Dynamics CRM installation. What I've done in the past is do full backups of SQL Server on a nightly basis with hourly transaction log backups on the databases. Additionally, backing up third party databases, folders, etc. is a good measure. Below is the checklist that I use to make certain not only our company databases are backed up efficient and hourly.
- Nightly full SQL Server backup of the following databases
- c360_MSCRM - We utilize c360 for every installation
- Custom_MSCRM - This is a custom table we have and is set to simple mode that I use for an AutoNumber routine, SharePoint integration, custom views, etc. as one NEVER makes customizations to the core MSCRM database as this breaks support for the system
- Hourly transaction log SQL Server backup of the following databases
- That's it as the other databases are set to SIMPLE database mode so transaction logs aren't needed
- Export of entity metadata - Although this is part of the databases above I also make certain to always backup the metadata separately as well. Below is the naming convention I use which mkaes sort, searching and finding of the files easy within a file structure
- CompanyAbbreviation-Date_20071013-Customizations-v00.xml - The first export is alwlays -v00
- Each day the convention starts over with teh first one each day being v01 and then after a few hours of customizations (or after lunch) I create a v02, v03, etc. This can be considered overkill but from a recoverability standpoint it makes solid sense
- Backup of files
- C:\Program Files\Microsoft CRM - I typically will backup (ZIP) the entire directory after the initial install, again with the -v00 so I know this is the original backup and then do additional backups as workflows, configuration files, etc. are changed. I also backuup the configuration files prior to any changes. Each night the standard server backup backs up this information as well as a final level of backup.
- C:\Program Files\c360 Solutions - Again same as above and is only if you have c360 installed
- Reports
- Although it's easy to recover the core reports with SQL Server Reporting Service you may make modifications to these reports and also add reports to the system. These reports should be backed up as well.
- The Visual Studio solution should be backed up and if possible document versioning incorporated as well. I utilize Microsoft Team System to provide this functionality.
- Backup the encryption key of the reporting services server
- Web Services
- Almost every installation we have custom web services installed for handling SharePoint site creation, AutoNumber routines, etc. and these files should be backed up
- Documentation
- The very last step is to write up a complete set of documentation of what's being backed up but also, and possibly more importantly, how to do the disaster recovery restoration for both one or two areas as well as the entire system.