Capitalize First String Character of a word in Text Field of Dynamics CRM 2011
So, One of the Post in LinkedIn asking if anyone can help with a Script that can Capitalize First String Character of a word in Text Field of Dynamics CRM 2011.
For eg. If i have a custom Full Name Field or Address filed. If User enters like 1107 medowville lane,
The script should automatically converts it to Pascal Casing like, 1107 Medowville Lane.
I thought to give it a try and here is the full functional code.
function ConvertFirstCharToCaps()
{
var attribute = Xrm.Page.getAttribute("new_address"); // Change the Schema Name here
if(attribute != null)
var str = attribute.getValue();
var pieces = str.split(" ");
for ( var i = 0; i < pieces.length; i++ )
{
var j = pieces[i].charAt(0).toUpperCase();
pieces[i] = j + pieces[i].substr(1);
}
Xrm.Page.getAttribute("new_address").setValue(pieces.join(' '));
}
It can be converted to Parametrized Function, but here i am just giving an idea how this code can work on each field.
Hope this will help, Please change the Attribute name as per your Attribute Schema Name.
Thanks.
So, One of the Post in LinkedIn asking if anyone can help with a Script that can Capitalize First String Character of a word in Text Field of Dynamics CRM 2011.
For eg. If i have a custom Full Name Field or Address filed. If User enters like 1107 medowville lane,
The script should automatically converts it to Pascal Casing like, 1107 Medowville Lane.
I thought to give it a try and here is the full functional code.
function ConvertFirstCharToCaps()
{
var attribute = Xrm.Page.getAttribute("new_address"); // Change the Schema Name here
if(attribute != null)
var str = attribute.getValue();
var pieces = str.split(" ");
for ( var i = 0; i < pieces.length; i++ )
{
var j = pieces[i].charAt(0).toUpperCase();
pieces[i] = j + pieces[i].substr(1);
}
Xrm.Page.getAttribute("new_address").setValue(pieces.join(' '));
}
It can be converted to Parametrized Function, but here i am just giving an idea how this code can work on each field.
Hope this will help, Please change the Attribute name as per your Attribute Schema Name.
Thanks.
No comments:
Post a Comment