PDA

View Full Version : How do I set a field as Null


ABC123

MadDexter
09-18-2014, 11:59 AM
Hi, First question here so be gentle lol

I have a button which concatenates 9 address fields on a form into a single field to make for easier data entry and copying addresses from emails. This is using Events>OnPush>Set Field Values in the Expression Builder of the Code Editor. I used the comma_to_crlf command to add line feeds in the final field:

comma_to_crlf(
Ship_Address_1 - ","
+ Ship_Address_2 - ","
+ Ship_Address_3 - ","
+ Ship_Address_4 - ","
+ Cust_Address_5 - ","
+ Ship_City - ","
+ Ship_State_Region - ","
+ Ship_Postal_Code - ","
+ Ship_Country )

There are 2 things that need to be done before rolling out on the desktop application.

1) How do I test fields in the code editor so that blank fields are ignored in the expression above, so avoiding multiple blank lines in the final address field;

2) What is the command/syntax used to set the now redundant fields to a Null value.

Thanks.

Stan Mathews
09-18-2014, 12:14 PM
Instead of what you have create a calculated field for the form

addr_to_use = comma_to_crlf(
if(alltrim(Ship_Address_1)>"",Ship_Address_1 - ",","")
+ if(alltrim(Ship_address_2>"",Ship_Address_2 - "," ,"")
+ if(alltrim(Ship_Address_3>"",Ship_Address_3 - ",","")
+ if(alltrim(Ship_address_4>"",Ship_Address_4 - "," ,"")
+ if(alltrim(Cust_Address_5>"",Cust_Address_5 - ",","")
+ if(alltrim(Ship_City>"",Ship_City - ",","")
+ if(alltrim(Ship_State_Region> "",Ship_State_Region - ",","")
+ if(alltrim(Ship_Postal_Code> "",Ship_Postal_Code - ",","")
+ if(alltrim(Ship_Country>"",Ship_Country,"") )

Unclear what the now redundant fields might be.

MoGrace
09-18-2014, 12:22 PM
Hi Brian,
Welcome to the board.

Check out the remove_blank_lines() function.

MadDexter
09-18-2014, 12:40 PM
Instead of what you have create a calculated field for the form

addr_to_use = comma_to_crlf(
if(alltrim(Ship_Address_1)>"",Ship_Address_1 - ",","")
+ if(alltrim(Ship_address_2>"",Ship_Address_2 - "," ,"")
+ if(alltrim(Ship_Address_3>"",Ship_Address_3 - ",","")
+ if(alltrim(Ship_address_4>"",Ship_Address_4 - "," ,"")
+ if(alltrim(Cust_Address_5>"",Cust_Address_5 - ",","")
+ if(alltrim(Ship_City>"",Ship_City - ",","")
+ if(alltrim(Ship_State_Region> "",Ship_State_Region - ",","")
+ if(alltrim(Ship_Postal_Code> "",Ship_Postal_Code - ",","")
+ if(alltrim(Ship_Country>"",Ship_Country,"") )

Unclear what the now redundant fields might be.

Hi Stan and thanks.

Not sure what your functions do yet but will try tomorrow.. it almost packing up time here.

The redundant fields are the fields that contained the individual address lines which have been copied to the combined address field, but still contain the individual data. I want these to be Null for the appearance of the form until they are removed completely.

Cheers.

Stan Mathews
09-18-2014, 12:46 PM
Robin's suggestion is simpler.

remove_blank_lines(comma_to_crlf(
Ship_Address_1 - ","
+ Ship_Address_2 - ","
+ Ship_Address_3 - ","
+ Ship_Address_4 - ","
+ Cust_Address_5 - ","
+ Ship_City - ","
+ Ship_State_Region - ","
+ Ship_Postal_Code - ","
+ Ship_Country ))

should do it.

My suggestion is the way we did it in the old days before some of the bells and whistles were added.

MadDexter
09-18-2014, 12:59 PM
Couldn't wait so I tried Stan's, but that needs more tweeking as I am getting an "incomplete" error in the expression editor.

Robin's worked like a charm. Thanks to you both.

Now if I could only set the redundant (ie completed, but no longer needed) data fields to Null.

I'm definitely leaving now :-)

Cheers, Bri

Stan Mathews
09-18-2014, 01:20 PM
Was trying to cut and paste on screen instead of copying it to Alpha. Left out some right parens. Should be

addr_to_use = comma_to_crlf(
if(alltrim(Ship_Address_1)>"",Ship_Address_1 - ",","")
+ if(alltrim(Ship_address_2)>"",Ship_Address_2 - "," ,"")
+ if(alltrim(Ship_Address_3)>"",Ship_Address_3 - ",","")
+ if(alltrim(Ship_address_4)>"",Ship_Address_4 - "," ,"")
+ if(alltrim(Cust_Address_5)>"",Cust_Address_5 - ",","")
+ if(alltrim(Ship_City>)"",Ship_City - ",","")
+ if(alltrim(Ship_State_Region)> "",Ship_State_Region - ",","")
+ if(alltrim(Ship_Postal_Code)> "",Ship_Postal_Code - ",","")
+ if(alltrim(Ship_Country)>"",Ship_Country,"") )

Stan Mathews
09-18-2014, 01:40 PM
If you're speaking of blanking out the visible form fields, set the value property to "" after you've filled the composite field. If you want to blank all the individual address fields in the table, create an update operation that sets each to "".