Calculated Field Behavior?

OK:

Excuse my ignorance again, because I’m new to all this.

I have a number field called “mode”

I have a Calculated Text field called “mode_display” with a calc of "If (mode=1, Return “TextA”, else, Return “TextB”.),

The script is valid.

Now when I go to my Form, I expect to be able to change “mode” from 1 to 0 and have Mode_display change appropriately. Instead, mode constantly resets to 1, and I can’t edite Mode_display either (which I would expect). So why can’t I change mode and see mode_display update?

Also, if I wanted to have Mode be a radio button that toggles between 1 and zero, but displays “TextA” and “TextB” as the options, how do I do that? In Filemaker I make a 1/0 lookup and hid the text values by shrinking the field and then putting my own “text labels” next to the values. In servoy, when I try to shrink the Radio Button field, I get big scroll bars.

I’m sure I’m missing basic things here, just have to learn Servoys tricks.

Thanks,
Lee

Lee,

The code should be:

if(mode == 1)
{
    return 'TextA'
}
else
{
    return 'TextB'
}

NOTE: The two “=” marks in the IF. You use TWO equals signs for comparison and one for assignement.

I think it might be your operator, I have and still make that mistake allot

try

if (mode == 1)
{
return ‘TextA’
}

else
{
return ‘default_Value’
}

Ahhh, I see. Sorry missed that.

I’m not a Java person as you can tell. ;-)

Guess I better “get with the program”.

Thanks,
Lee

OK,

That solved one problem. If I want the Calculated display field to redraw as soon as I exit the field, what do I need to do?

How do I handle this with a Radio Button?

Also, how do “database controlled” defaults work? If I set values with a trigger, when will the values be updated in Servoy?

Thanks again for everyone’s patience while I wade through all this.

Regards,
Lee Snover

create a method,
select the field (in designer mode)
attach the method to the on the ‘focus lost’ property

as far as a radio button in your value list you can set the data provider to a property other then what displays in the list, I believe you do it with a pipe

value list:

Mode A | 1
Mode B | 1

to trigger a method when the focus is lost from a filed:

create a method (field_A = null),
select the field (in designer mode)
attach the method to the on the ‘focus lost’ property

not sure if this is what you are trying to accomplish

ebrandt:
create a method,
select the field (in designer mode)
attach the method to the on the ‘focus lost’ property

as far as a radio button in your value list you can set the data provider to a property other then what displays in the list, I believe you do it with a pipe

value list:

Mode A | 1
Mode B | 1

to trigger a method when the focus is lost from a filed:

create a method (field_A = null),
select the field (in designer mode)
attach the method to the on the ‘focus lost’ property

not sure if this is what you are trying to accomplish

ebrandt:

Thanks, it’s someplace to start. I understand the property, but what do I need to put in the method to cause the Calculated field to recalculate?

Thanks,
Lee Snover

I am not sure , if you mean to save the current change then you could do a save data().

If you are trying update existing records the reflect a new calculation, you have to loop through your records.

If your calc is stored, it should not allow you to edit it, and should update as soon as you save data, or click outside the field.