Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Friday, August 29, 2025 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Architect Forums - SalesLogix Scripting & Customization
Forum to discuss writing script in Architect plugins for SalesLogix & general SalesLogix customization topics (for Windows client only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Scripting & Customization | New ThreadView:  Search:  
 Author  Thread: Boolean Field from NULL to F
Michael Rogers
Posts: 70
 
Boolean Field from NULL to FYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 06 Dec 06 10:57 AM
fiogf49gjkf0d
I thought I had seen this discussed here before but can't find it. I have a dataform with multiple checkboxes. If the user doesn't select it, I want an "F" in the field. This is an issue for one of my high priority (maintenance?) report writers who refuses to modify her report to display these NULL Records as False. Did I read that ADO won't allow you to change a boolean field from NULL to "F"?

Thanks for any hints!

Michael
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Boolean Field from NULL to FYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 06 Dec 06 12:27 PM
fiogf49gjkf0d
You could add a constraint on the table so the default value is 'F'. Here's something that Timmus Agersea posted in the business partner newsgroups recently:

Quote:
The following TSQL will generate the alter table commands to set a default value of 'F' for the columns with a data_length = 1. I would only apply the alter table statements for tables that have "customer data". The main goal of this is to help users with query building. No longer will they need to worry about nulls.

SELECT
'ALTER TABLE ' + T.Table_Schema + '.' + T.Table_Name + ' ADD CONSTRAINT DF_'
+ T.Table_Name+ '_' + C.Column_Name + ' DEFAULT ''F'' FOR ' + C.Column_Name
FROM
Information_Schema.Columns C
INNER JOIN Information_Schema.Tables T
ON T.Table_Name = C.Table_Name
AND T.Table_Type = 'Base Table'
WHERE
C.Character_Maximum_Length = 1
AND C.Data_Type = 'char'
ORDER BY
C.Table_Name, C.Column_Name


Sample output
ALTER TABLE sysdba.ACCOUNT ADD CONSTRAINT DF_ACCOUNT_DONOTSOLICIT DEFAULT 
'F' FOR DONOTSOLICIT


As always, use at your own risk and this was built and tested on SQL Server.
[Reply][Quote]
Jeremy Brayton
Posts: 491
Top 10 forum poster: 491 posts
 
Re: Boolean Field from NULL to FYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 06 Dec 06 12:35 PM
fiogf49gjkf0d
SLX boolean is a char(1) with "T", "F", or NULL. A SQL boolean is either true/false I believe. So technically ADO doesn't allow you to change a boolean field but that doesn't apply since SLX booleans are just 1 character string fields.

I thought SLX defaulted checkboxes to "F" because a lot (if not all) of my custom tables have no NULL values without any special help from me. This may have been a change introduced in 6.1 or involves something special for it to work. Some system tables like Account or Contact tend to default to NULL most likely because they're created from SQL instead of using the data manager.

A sure way to fix the problem is to loop through Form.Controls setting checkbox.Text = "F" or set each one manually in the Form's OnChange event. Any checked controls will show as "T" and those left should be created as "F" by the data manager.
[Reply][Quote]
Timmus Agersea
Posts: 328
 
Re: Boolean Field from NULL to FYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 06 Dec 06 2:42 PM
fiogf49gjkf0d
Unless you databind a SLX boolean column in the add form the record will be inserted with a null value. It is a sound approach to use hidden controls to ensure that all the boolean fields are set to 'F' but this requires customization and it requires customization on EVERY form that inserts data into a table with SLX Booleans.

Timmus
[Reply][Quote]
Michael Rogers
Posts: 70
 
Re: Boolean Field from NULL to FYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 11 Dec 06 10:39 AM
fiogf49gjkf0d
Ryan,

Thank you: that worked great! We had previously used Timmus' aproach and didn't want to do that on every form as he mentioned

Michael
[Reply][Quote]
Timmus Agersea
Posts: 328
 
Re: Boolean Field from NULL to FYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 11 Dec 06 12:30 PM
fiogf49gjkf0d
Actually, my approach is the one using the SQL Default Constraints. The databinding approach is a pain.

Timmus
[Reply][Quote]
Dave McGill
Posts: 47
 
Re: Boolean Field from NULL to FYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 27 Jan 09 4:06 PM
The script failed when I tried to run it in SLX Admin. Is it intended to be run in SQL?
If it runs in SQL, how do you get it to the remote users?

This is the statement I tried to run:
ALTER TABLE SYSDBA.LCMS_C_AM_MAIN ADD CONSTRAINT DF_LCMS_C_AM_MAIN_ALUMNI DEFAULT 'F' FOR ALUMNI

our table name is LCMS_C_AM_MAIN, the field name is ALUMNI.
[Reply][Quote]
Timmus Agersea
Posts: 328
 
Re: Boolean Field from NULL to FYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 27 Jan 09 4:19 PM
This is not a sync friendly statement.

Timmus
[Reply][Quote]
Dave McGill
Posts: 47
 
Re: Boolean Field from NULL to FYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 27 Jan 09 4:21 PM
Will the tables get the constraint if I cut new remotes? Or can this not get to the remotes at all?
[Reply][Quote]
Timmus Agersea
Posts: 328
 
Re: Boolean Field from NULL to FYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 27 Jan 09 4:59 PM
I thought it would, Dave, but I was wrong. I added a default value of 'F' for Account.NationalAccount and cut a remote database and the remote does not have the same constraint. I am testing with 7.5 so your mileage may vary but I suspect it will not.

Sorry for the bad news...

Timmus
[Reply][Quote]
Dan Carvin
Posts: 227
 
Re: Boolean Field from NULL to FYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 29 Jan 09 5:16 PM
My approach would be when the form is opened in insert mode, I would set all checkboxes to Checked=False. If the user doesn't check it, it writes a F to the database, does it not? I know it does write an F if a previously checked box is unchecked.

You can then clean up existing records in a sync-friendly fashion by running this in the SQL Admin tool

update table set field = 'F' where field is null


[Reply][Quote]
Michael Rogers
Posts: 70
 
Re: Boolean Field from NULL to FYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 15 May 09 3:29 PM
Dan, I don't know if you ever got an answer to this. In my pre-v7.2.1 experience, I was never able to get SLX to write a "F" to a SLX boolean field as the first value. I had to write a "T" first, then update it to "F". I don't know if it still behaves this way as I got tired of beating my head against the issue.

Michael
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2025 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 8/29/2025 8:20:04 AM