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
SaintMichaelSaintMichael 

Collecting boolean values from check boxes

My Asset objects have a boolean field called Opt_Out__c.

 

A single account can have multiple Asset objects.

 

I need to list each Asset object's Opt_Out__c field as a checkbox

and be able to update each Asset object's Opt_Out__c field.

 

 

Any suggestions to get this to work?

 

The page shows nicely, but how can I capture the selected ID for each Asset object.

Keep in mind that if an Account previously decided to 'opt out,' the check box should be selected

when the page loads!

 

VisualForce: Not sure which pageBlockSectionItem I should go with?

<!-- in this one, how do I get the id for the Asset object?-->	
<apex:pageBlockSectionItem >
                        <apex:outputPanel >
                            <apex:dataTable value="{!assets}" var="a">
                                    <apex:column >
                                        <apex:outputField value="{!a.Name}" />
                                    </apex:column>
                                    <apex:column >
                                        <apex:facet name="header">Opt Out</apex:facet>
                                        <apex:inputCheckbox value="{!a.Opt_Out__c}" />
                                    </apex:column>
                                </apex:dataTable>
                            </apex:outputPanel>
                        </apex:pageBlockSectionItem>
                        
                        
     <!-- in this one, how do set the check box as selected, if need be, for the Asset object?-->                    
                        <apex:pageBlockSectionItem >
                            <apex:outputPanel id="thePanel">
                                <apex:outputLabel value="Select the items you would like to receive:" />
                                <apex:selectCheckboxes value="{!assetsToSave}"
                                    layout="pageDirection">

                                    <apex:selectOptions value="{!options}" />
                                </apex:selectCheckboxes>
                            </apex:outputPanel>
                        </apex:pageBlockSectionItem>
soofsoof

Use the first pageBlockSectionItem, and update 'assets' List variable when user clicks 'Save' (or whatever button you have).

 

Thanks.