How do you set default for form field dynamically?

Started by Candy M., October 25, 2008, 12:37:01 AM

Previous topic - Next topic

Candy M.

We would like to set the default for a form field dynamically.

Are there any methods like   setFieldHidden(), etc?

We would like to search through DOM tree and set the default.

Any help is appreciated.

Thanks,
Candy

Sebastien F.

Candy,

I let support people write you an example using the OM interface.
The attribute to be set is "defaultValue", in FormField, Matrix or TableColumn nodes.

Some questions:
- Why don't you use WITHOUT DEFAULTS option and set the field default values in program variables?
- Are you using multiple dialogs (DIALOG instruction)?

Seb

Candy M.

Seb,
    We do use INPUT WITHOUT DEFAULTS now and set it in
program variables.
     What we would like to do is provide a utility so that user
can hide fields, activate/inactivate fields, and set their own
defaults.   I thought it might be easier setting the defaults
in the DOM tree and more general so that the code we use, we
could use everywhere and not depend on setting program
variables.

Candy

Sebastien F.

Candy, (sorry for the late answer)

I would not use the AUI tree to implement an application feature like customizable default values.

From my understanding, it's just a matter of default value storage.... right?

Why don't you just use a simple database table like:

CREATE TABLE user_defaults
(
   target_name VARCHAR(50) NOT NULL,
   user_name VARCHAR(50) NOT NULL,
   value VARCHAR(100),
   PRIMARY KEY (target_name, user_name)
)

And write some API around to get/set the values?

   CALL defaults_setValue("order.ord_state", user_name, "valid")
   LET rec_order.ord_state = defaults_getValue("order.ord_state", user_name, <default-default>)

The get function would need to interpret special values like TODAY, and return a default-default value if nothing found in table:

   SELECT value INTO p_value FROM user_defaults
        WHERE target_name = name AND user_name = uname
   IF SQLCA.SQLCODE == NOTFOUND THEN RETURN default_default END IF
   IF p_value == "TODAY" THEN RETURN TODAY END IF
   IF p_value == "CURRENT" THEN RETURN CURRENT END IF
   RETURN p_value

?

Seb

Candy M.

Thanks, Seb for your input.

When setting the values on the form, I wanted to
avoid having to set it to a program variable.  I thought
it would be nifty to have one function that I could call
and set the default values in the AUI tree instead of
having to set the program variables,  thus saving on
lots of code.

Candy