Formatting a field
Can someone help me with formatting in a field. I want to have a captial letter first and lower case after, also phone number, and ss#, etc.
15 replies
-
For upper first letter:
For phone format use this code in the Trigger After Update box:
---
let myNumber := trim(text(Phone));
let p := length(myNumber);
let myCars := "";
var myStart := 0;
var myEnd := 1;
for i in range(0, p) do
var myNum := substring(myNumber, myStart, myEnd);
if myNum = "0" or myNum = "1" or myNum = "2" or myNum = "3" or myNum = "4" or myNum = "5" or myNum = "6" or myNum = "7" or myNum = "8" or myNum = "9" then
myCars := myCars + myNum;
myStart := myStart + 1;
myEnd := myEnd + 1
else
myStart := myStart + 1;
myEnd := myEnd + 1
end
end;
let Area := substring(myCars, 0, 3);
let Num := substring(myCars, 3, 6);
let Num2 := substring(myCars, 6, 10);
Phone := "(" + Area + ")" + " " + Num + "-" + Num2---
* You can change the format to your needs by changing the last fout lines
-
Thanks, I was able to figure out the text field, but I can't seem to figure out the phone number field.
I would like all my phone numbers to look like this "555-555-555" no parenthesis around area code.
-
Replace the last line with this:
Phone := Area + "-" + Num + "-" + Num2
-
Thank you that worked perfectly. I would like to do the same thing for SS#, can you help me with that please.
-
Hi Joe,
what is SS#?
-
Social Security Number, it is used in the US for tax perposes. it is always written out like this "123-45-6789"
Thanks for your help I realy appreate it.
-
No problem @Joe.
Here is the code for SSN field:
---
let myNumber := trim(text(SSN));
let p := length(myNumber);
let myCars := "";
var myStart := 0;
var myEnd := 1;
for i in range(0, p) do
var myNum := substring(myNumber, myStart, myEnd);
if myNum = "0" or myNum = "1" or myNum = "2" or myNum = "3" or myNum = "4" or myNum = "5" or myNum = "6" or myNum = "7" or myNum = "8" or myNum = "9" then
myCars := myCars + myNum;
myStart := myStart + 1;
myEnd := myEnd + 1
else
myStart := myStart + 1;
myEnd := myEnd + 1
end
end;
let Num1 := substring(myCars, 0, 3);
let Num2 := substring(myCars, 3, 5);
let Num3 := substring(myCars, 5, 9);
SSN := Num1 + "-" + Num2 + "-" + Num3---
Enjoy
-
Thanks Nick, But I must be doing something wrong because after I put in a SS# and tab to the next field the number I entered disapears from the field.
The field name I'm using is "SSN Number" and it is a Number field.
IN the code you gave me I changed the first line to - " trim(text(SSN)) to trim(text('SSN Number')) "
and the last line to - " 'SSN Number' := Num1 + "-" and so on...
Please tell me what I'm doing wrong.
-
@Joe, a number field can't accept dashes (-).
So you have two choices: convert it to a text field
or
create a new formula field e.g. 'SSN Display' and put the code there.
-
Oh Ok, now I get it, I did not realize that a number field would not accept dashes.
Thank you so much for your help.
Content aside
- 1 mth agoLast active
- 15Replies
- 2856Views
-
3
Following