Expand my Community achievements bar.

SOLVED

Exclude empty field (null) from a combined data field

Avatar

Former Community Member

Hi

I have a simple (i hope) question i'm stuck on...

At one stage in our form we ask for home, cell and work numbers. These are optional.

at a later point we want to re-use the phone contact information provided earlier

at the second place (call it field X for our example) where this data is use I was just going to go something like

this.rawValue = A.rawValue + B. rawValue + C. rawValue;

where A, B, C are the earlier home, work and cell phone fields  and this = X.

But this will produce inserted NULL fields if the user leave the initial field blank (e.g. if they only have a cell and so leave home empty).

So I would like to test to see if the field is null before it is used

can someone suggest some code that allows for the following logic

x.rawValue = A.rawValue + B.rawValue + C.rawValue SO LONG AS A, B AND C ALL HAVE PHONE NUMBERS ENTERED

else if ONLY A AND B have data then x.rawValue = A.rawValue + B.rawValue

else if ONLY A and C

or only A

etc

then the corresponding filled only fields from x's rawvalue ---

I've experimented with various syntax but cant get it quite right --- can anyone help or does someone have a sample  of something similar i can mold to my needs? 

thanks in advance

1 Accepted Solution

Avatar

Correct answer by
Level 10

var strAValue, strBValue, strCValue

//Get A Value

if(A.rawValue ==null || A.rawValue =="")

     strAValue  = "";

else

     strAValue = A.rawValue;

//Get B Value

if(B.rawValue ==null || B.rawValue =="")

     strBValue  = "";

else

     strBValue = B.rawValue;

//Get C Value

if(C.rawValue ==null || C.rawValue =="")

     strCValue  = "";

else

     strCValue = C.rawValue;

X.rawValue = strAValue + strBValue + strCValue;

Hope this helps..

Thanks

Srini

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

var strAValue, strBValue, strCValue

//Get A Value

if(A.rawValue ==null || A.rawValue =="")

     strAValue  = "";

else

     strAValue = A.rawValue;

//Get B Value

if(B.rawValue ==null || B.rawValue =="")

     strBValue  = "";

else

     strBValue = B.rawValue;

//Get C Value

if(C.rawValue ==null || C.rawValue =="")

     strCValue  = "";

else

     strCValue = C.rawValue;

X.rawValue = strAValue + strBValue + strCValue;

Hope this helps..

Thanks

Srini