Skip to main content
Level 2
Apr 26, 2017 11:38 AM UTC
Solved

Schema Boolean Default value

Hi All,

I'm trying to create a Boolean field into my custom schema with default value set as "true".

I tried with the following statement:

<attribute default="true" label="Export to FOX" name="foxExportFlgg" type="boolean"/>

Unfortunately the default value is always set as false.

This is the generated SQL code:

ALTER TABLE NmsDelivery ADD iFoxExportFlgg SMALLINT;

UPDATE NmsDelivery SET iFoxExportFlgg = 0;
ALTER TABLE NmsDelivery ALTER COLUMN iFoxExportFlgg SET Default 0;
ALTER TABLE NmsDelivery ALTER COLUMN iFoxExportFlgg SET NOT NULL;

 

Could you please help me?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
vraghav
vraghavAccepted solution
Adobe Employee
Apr 26, 2017 11:57 AM UTC

Hi,

Please use the sqlDefault attribute and set it to value of choice.

Boolean field at SQL level transforms to an integer of 8 bit and can hold value as 0 or 1. 0 corresponds to False and 1 corresponds to True.

If you use the code like this it will work as required

<attribute default="true" label="Export to FOX" name="foxExportFlgg" type="boolean" sqlDefault="1" />

Hope this helps.

Regards,

Vipul

3 replies

Adhiyan
Adobe Employee
Adobe Employee
Apr 26, 2017 11:57 AM UTC

Hello Andrea,

I believe the SQL script is generated when you try to update the DB structure . If this is true , the script is editable. 

Can you change the SET DEFAULT to 1 from 0 and see if the default changes to True.

Translate
vraghav
Adobe Employee
vraghavAdobe EmployeeAccepted solution
Adobe Employee
Apr 26, 2017 11:57 AM UTC

Hi,

Please use the sqlDefault attribute and set it to value of choice.

Boolean field at SQL level transforms to an integer of 8 bit and can hold value as 0 or 1. 0 corresponds to False and 1 corresponds to True.

If you use the code like this it will work as required

<attribute default="true" label="Export to FOX" name="foxExportFlgg" type="boolean" sqlDefault="1" />

Hope this helps.

Regards,

Vipul

Translate
Level 2
Apr 26, 2017 12:58 PM UTC

Thank you very much for your support guys!

It is working.

Best,

Andrea

Translate