function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dandantedandante 

determining default state of boolean (checkbox) field

I created a custom field called TestCheckbox. I specified that it was to be unchecked by default.

In my code when I look at the Field object associated with this field, its type shows up as "boolean. There doesn't seem to be an obvious way to find out what the default state of the checkbox is supposed to be.

I am writing a component to render a checkbox and I want it to check the box if it is supposed to be on by default. I'm sure I'm missing something obvious. How do you do that?

Maybe I should step back for a second and ask a larger question. I want to build a component that automatically generates a form for all the fields in a Lead object. If a field is a checkbox, I want to render a checkbox. If the field is text, I want to render a textbox, etc. Is this possible? So far I have run into a couple hurdles including the one above.

Another issue is: How do you create a group of radio buttons?
The approach I took was to use a picklist, since a select list and a group of radio buttons are the same thing from the server's point of view. But I need to tell my code whether I want it rendered as a radio button group or drop down list. So I put the word "radio" in the Description field when I created the field.
But now it looks like I can't get to the Description field from the Field object in my code.

Any ideas?

Thanks

Message Edited by dandante on 04-14-2006 04:00 PM

SteveBowerSteveBower

Have you looked at the Describe Object call?  That gives you back all the information you need to craft DOM objects on the fly although it may be tedious.

Radio buttons are well covered all over the web.  http://www.echoecho.com/htmlforms10.htm was the second link that came up from a google search.

If you'd like to have a higher level conversation about this stuff, feel free to write me offlist.

Steve.

SteveBowerSteveBower
Dan ping'ed me offlist, and this is the result of my deeper look into his question.


Hi Dan, hmm... you are correct.

As near as I can see there is no way to get the default value for a field, nor its description.

You can determine if there *is* a default value, but not what that value is. 

For Checkboxes it appears that defaultedOnCreate is always true.  Even instantiating a dynabean doesn't help because it's only using the results from the Describe call, and the information just isn't there.

My apologies, I thought I had done this before, but, upon looking, I always knew what I wanted the defaults to be, so I didn't look them up.

You could, of course, instantiate an object, and issue a Create call for that object.  Then, the object would really exist, you could retrieve it and the default value would have been filled in for you, but I assume we would both think that's a disgusting and slow way to have to do things.

As I look at your second question (which I only gave a shallow read to earlier), I don't see any pretty way to do it.  You'd have to pass some flag as part of the field definition, and, as we've seen with the default value, that's tough to do.  No place to "overload" the information.

There's always the option of creating your own "addendum" to the Field descriptions.  You could create a Document stored in the Salesforce document repository which your S-Controls would open first thing.  That document could have whatever information you want to put in there which you could use to augment the native Field descriptions however you like with layout hints, default values, etc.  At least you could keep it all organized in the same place.

All in all you're right, this is fugly.   Sorry I didn't give you a more complete response earlier.

Steve.