« Don’t delete CRM System Customizer Role – and how to Create it if you did! | Main | Microsoft CRM 4.0 Outlook E-mail Tracking »

January 30, 2008

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00e54fb34b6f883300e55001735f8833

Listed below are links to weblogs that reference Looking For Suggestions Regarding Account Numbers:

Comments

MDodd

I have debated this several times with fellow CRM'ers. The solution I think works best is to use a combo of the parsing the Account Name and appending it with the Julian Date. But since JScript 5.6 doesn't have a getJulianDate() method, I concoted my own, with an added touch of a random number generator using the Math.random() method. Put the following code in the OnChange event of the AccountName field. Then, disable the AccountNumber field. Oh, yeah, take out the alerts too.

// Generate AccountNumber
if (crmForm.FormType == 1)
{
var aName = crmForm.all.name.DataValue;
aName = aName.substr(0,3);
aName = aName.toUpperCase();
var iNum = Math.random();
iNum = iNum.toString();
iNum = iNum.substr(8,4);
alert(iNum);
var myDate = new Date();
julDate1 = myDate.getDate();
julDate1 = julDate1.toString();
julDate2 = myDate.getMonth();
julDate2 = julDate2.toString();
julDate = julDate1.concat(julDate2);
alert(julDate);
actNum = aName.concat(julDate, iNum);
crmForm.all.accountnumber.DataValue = actNum;
crmForm.all.accountnumber.ForceSubmit = true;
}

Not very economical, but it works fine.
What's at work here are 3 things:

1.) My psuedo "Julian Date". It may not be as unique as the full julian date, but every day of the current year will produce a unique set of numbers (today is 2902)
2.) This is appended with 4 digits in the random number. So no 2 users in a given day will produce the same random number (in theory)
3.) The first 3 letters of the Account Name. Even Wallgreens and WallMart will get a different Random number.

With these 3 "Checks and Balances" in place, you'd be hard pressed to get a duplicate Account Number.

However, if you're really slick, you could write duplicate checking function using a Web Service call that queries the FilteredAccount view, checking for a record that equals the value in the AccountNumber field. If the response that comes back is not null, restrict the save, re run the OnChange for a new Random number.

--Michael

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been saved. Comments are moderated and will not appear until approved by the author. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Comments are moderated, and will not appear until the author has approved them.

Search The Blog

  • Search the Blog
     

    WWW
    this blog

Twitter Updates

    follow me on Twitter