Format telephone field in CRM 4.0 using javascript onChange event August 20, 2008
Posted by Joel Kriel in CRM 4.0 & .Net development.Tags: crm 4.0, crm 4.0 onchange javascript, crm telephone format, javascript try catch
1 comment so far
Here is a simple javascript to format telephone numbers in CRM. This is to be used in the onChange event at the field level. Throw this in there to format telephone numbers using (XXX) XXX-XXXX. Pretty simple code that I found and slightly modified to meet our clients need.
var oField = event.srcElement;
if (typeof(oField) != “undefined” && oField != null)
{
var sTmp = oField.DataValue.replace(/[^0-9]/g, “”);
switch (sTmp.length)
{
case 10:
oField.DataValue = “(” + sTmp.substr(0, 3) + “) ” + sTmp.substr(3, 3) + “-” + sTmp.substr(6, 4);
break;
default:
alert(‘Phone must contain 10 numbers.’);
break;
}
}
I found this code while searching google. It is from Mitch Milam’s blog and the entry is for CRM 3.0 SDK: Phone number format example bug fix. Thanks Mitch!
Auto populate fields in CRM 4.0 using Javascript onChange event August 14, 2008
Posted by Joel Kriel in CRM 4.0 & .Net development.Tags: crm 4.0, javascript crm, javascript switch, try catch, try catch javascript
add a comment
A few enhancements from our clients that have been coming down the pike is to auto-populate fields based on selection criteria from other fields, specifically the picklists. One client has a field that is used to select an ‘English honorific’ for the contact. (Mr., Mrs, Ms, etc.). Based on that selection, they want to pre-populate the salutation field with the last name and the prefix. (Mr. Smith)
Here is the code snippet that we can use to populate the salutation field based on the value of the picklist given via Javascript using switch. This is to be used on the obChange event of your specific attribute.
var MrMrs;
var LastName;
LastName = ”;
if (crmForm.lastname.DataValue != null)
{
LastName = crmForm.lastname.DataValue;
}
MrMrs = crmForm.new_mr_mrs.SelectedText
if (crmForm.salutation.DataValue == null)
{
crmForm.salutation.DataValue = MrMrs + ‘ ‘ + LastName;
}
Granted there are going to be many ways to do this, I just figured this might be the easiest for fellow developers to understand and thus support.
Cheers!
CRM 4.0 Lost Connection Error from Outlook Plugin in Systray August 8, 2008
Posted by Joel Kriel in CRM 4.0 & .Net development.Tags: crm 4.0, Enable Anonymous Access, lost connection crm 4.0, try catch
add a comment
After installing CRM 4.0 and installing the plug-in for Outlook, we have been getting this pop up error message in the system tray stating:
“Unable to Connect. Lost Connection to Microsoft Dynamics CRM. Microsoft Dynamics CRM will restore the connection when possible. To stop retrying, right-click and select Sign Out”.
So of course you’d assume that the plug-in for Outlook wouldn’t work since it doesn’t have a connection right? Well, not so fast. Everything in Outlook (tracking, synching contacts, create and updating tasks, etc, etc.) all worked fine! So the only downside to this error is that is pops up every 5 minutes. No big deal……
So after an hour of this error message I needed to get rid of it ASAP. Luckly I found a great post in the Google Groups Microsoft.Public.CRM forum. So here is the solution to that annoying problem.
Go in IIS -> Microsoft Dynamics CRM -> _imgs.
Right click and get to the properties -> Directory Security
In the Authenticate and Access Control, click the Edit button.
Make sure the Enable Anonymous Access is checked.
Goodbye lost connection error pop-up!
Auto track emails in CRM 4.0 from Outlook August 5, 2008
Posted by Joel Kriel in CRM 4.0 & .Net development.Tags: auto track emails in crm from outlook, crm 4.0, emails outlook, track emails crm 4.0, try catch crm
add a comment
So having successfully synched up contacts from CRM 4.0 into Outlook we know move onto how to automatically track emails into CRM from Outlook. After numerous hours of how to figure this out, I came across a post that helped greatly. It is from the Microsoft CRM Forum. Here was my issue, I was able to synch contacts and track email manually but I wanted the emails to be tracked automatically. I mean, technology is supposed to make your life easier right? So, in order to do this, you need to start out in CRM and modify the user profile.
CRM-> Settings -> Adminstration -> Users
Select the specific user and under the general tab (which whould be the default tab shown) there is a section called E-Mail Access Configuration.
Select the incoming to: Microsoft Dynamics CRM for Outlook.
If you would like CRM to send email outgoing, you can do so under the outgoing property but for my setup, we leave it at None.
Now, go into the dropdown option in Outlook
Outlook -> CRM -> Options
Go under the Email tab
Select the Check incoming email in Outlook….. (to auto track emails)
Select E-mail messages from CRM Leads, Contacts and Account under the Select the email messages to track section.
And that is it!
To run a test, I created a test account from an outside email account (hotmail, gmail, yahoo, etc) in CRM. Then went to my Outlook and synched up so now that new account in in my address book. Then I just sent an email from my outside account and it comes through all tracked!