• KevinBr
  • 19 Points
  • Member since 2012

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
  • 18

I have been coming across some odd behaviour using checkboxes and VF page/controllers and

would greatly appreciate if someone can guide me as to what I am doing wrong.



The grid is populated from a button on an Account page.

Going across, are the assets that are available on the account  (variable listing).

As it is variable, I am using a repeater process instead of a DataTable.

Each cell for the assets has a checkbox to "select all" of the contacts under it.

Going down, are the contacts for the account (variable listing).


The grid is a set of checkboxes; I am trying to capture the values from a custom

service table (AccountId,ContactId,AssetId,ActiveFlag) which will hold values

from the user's selections.


Account Name: XYZ


Contacts/Assets           Asset01 Asset02 Asset03 Asset04

                                           [x]          [ ]            [ ]            [ ]

Contact01                            [x]          [x]          [ ]            [ ]

Contact02                            [x]          [ ]            [x]          [ ]

Contact03                            [x]          [ ]            [ ]            [x]



#1 - The all feature works to enable the column, but does not work to uncheck the column

#2 - The checked values in the grid details don't seem to get set.

#3 - I need to persist the original settings from the custom table for comparison cases;

Ideally, a single case will be created for new requests/changes.

Currently I have been using the save button for debugging before/after grid changes;

Orig: TFFF,TFFF,TFFF,TFFF  (should be all False)

Chgs: TFFF,TFFF,TFFF,TFFF (appears the all feature took affect on both)



Source Page:
<apex:page sidebar="false" standardController="Account" extensions="myServiceGridController" tabstyle="Account" standardstylesheets="false" >
<apex:stylesheet value="{!$Resource.myServiceGridStyles}" />
<apex:form id="addAssetForm">
<apex:pageBlock id="Page" >
 <apex:pageBlockButtons location="bottom">
  <apex:commandButton value="Save" action="{!save}" />
  <apex:commandButton value="Cancel" action="{!cancel}" />

<table align="center" id="hdr" >
  <tr><td>Account Name: &nbsp; <apex:outputLink value="/{!account.Id}">{!account.Name}</apex:outputLink></td>

<!-- 01. Assets -->
  <table cellpadding="5" border="1" cellspacing="0" class="border"  >
  <apex:repeat value="{!assetList}" var="a" >
  <td><apex:outputLink styleclass="asset" value="/{!a.ast.Id}">{!a.ast.Name}</apex:outputLink>
  <p />
  <apex:inputCheckbox id="asset" value="{!a.Selected}" >
    <apex:actionSupport event="onclick" action="{!setSelectedColumn}" onsubmit="checkAll(this,'{!a.ast.id}')" rerender="assetBlock" >
    <apex:param name="c1" value="{!a.ast.Id}" assignTo="{!assetId}" />
  <apex:pageBlock id="assetBlock" rendered="false" />
  <apex:pageBlock id="matrixStart" rendered="false" />
<!-- 02. Contact, AssetBoxes; no re-rendering is needed -->
  <apex:repeat value="{!contactList}" var="c">
  <td><apex:outputLink styleclass="contact" value="/{!c.Id}">{!c.Name}
    <apex:param name="c1" value="{!c.Id}" assignTo="{!contactId}" />

<!-- 03. Contact, AssetBoxes; no re-rendering is needed -->
  <apex:repeat value="{!assetList}" var="a"  >
        <td class="datacell"  >
      <apex:inputCheckbox id="service" value="{!ServiceDetail}" title="{!a.ast.Id}"   >
    <apex:actionSupport event="onclick" action="{!setSelectedBox}" rerender="contactBlock" >
    <apex:param name="m1" value="{!c.Id}" assignTo="{!contactId}" />
    <apex:param name="m2" value="{!a.ast.Id}" assignTo="{!assetId}" />
    <apex:pageBlock id="contactBlock" rendered="false" />

<script type="text/javascript" > 
function checkAll(cb,astID) { 
  var inputElem = document.getElementsByTagName("input");
  for(var i=0; i<inputElem.length; i++)  {
    if(inputElem[i].title.indexOf(astID)!= -1 ) {
          inputElem[i].checked = cb;

Source Controller:
public with sharing class myServiceGridController {
    private final Account acct;

    private ApexPages.Standardcontroller controller {get; set;}
      public List<Contact> contactList;
      public List<serviceWrapper> originalServicesList;
      public List<assetWrapper> assetList {get; set;}
      public List<serviceWrapper> changedList {get; set;}
      public Boolean checkedAssetAll {get; set;}
      public Boolean checkedContactAsset {get; set;}
      public string assetId {get; set;}
      public string contactId {get; set;}
      public Boolean ServiceDetail {get; set;}
      public myServiceGridController(ApexPages.StandardController controller) {
        this.controller = controller;
        this.acct = (Account)controller.getRecord();
        string url = ApexPages.currentPage().getUrl();
        //system.debug('------------- VFController: Acct:' + acct.Name + '(url: ' + url + ')');
        if (originalServicesList == null ) {
            assetList = getAssetList();
            contactList = getContactList();
          originalServicesList = getOriginalServices();   //pulls up booleans on last service records
          changedList = originalServicesList;             //inits the array, but will be later altered by the user

            checkedAssetAll = false;
            checkedContactAsset = false;

      public PageReference  setSelectedColumn() {
        string assetSum = '';
        for (assetWrapper asw : assetList) {
            if (asw.ast.id == assetId ) {
                  checkedAssetAll = asw.selected;
                  for (serviceWrapper svw : changedList ) {
                        if (svw.ast.id == assetId ) {
                              svw.selected = checkedAssetAll;
          if (asw.selected == true ) {
             assetSum = assetSum + 'T';
          if (asw.selected == false ) {
               assetSum = assetSum + 'F';
          if (asw.selected != true && asw.selected != false) {
               assetSum = assetSum + '?';
          system.debug('------------- setSelectedColumn: ' + assetId + '/' + assetSum + '/' + checkedAssetAll);
          return null;

      public PageReference  setSelectedBox() {
          for (serviceWrapper svw : changedList ) {
              if (svw.ast.id == assetId ) {
                  if (svw.con.id == contactId ) {
                  //checkedContactAsset = svw.selected;
                  svw.selected = checkedContactAsset;
          system.debug('------------- setSelectedBox: ' + assetId + '/' + contactId + '/' + checkedContactAsset );

          return null;

      // this is to generate the asset list going across; 
      public string parseList (List<serviceWrapper> a) {
        Integer c=0;
        Integer j=0;
        string strSum = '';

        for (serviceWrapper svw : a ) {
          if (svw.selected == true ) {
               strSum = strSum + 'T';
          if (svw.selected == false ) {
             strSum = strSum + 'F';
          if (svw.selected != true && svw.selected != false ) {
             strSum = strSum + '?';
          c = c + 1;
          if (c >= assetList.size() ) {
            if (j<contactList.size()) {
              strSum = strSum + ',' ;
        return strSum;
      public List<assetWrapper> getAssetList() {
          List<assetWrapper> results = new List<assetWrapper>();
            for (Asset ast : [ SELECT Id, Name, Metric__c  FROM Asset 
                                          where  AccountId = :acct.Id order by Name ]) {
            results.add(new assetWrapper(ast,false));
            system.debug('------------- assetSize: ' + results.size() );
        return results;
      public List<Contact> getContactList() {
          List<Contact> results = new List<Contact>();
            results = [SELECT Id,Name  FROM Contact
                                              where AccountId = :acct.Id order by Name ];
            system.debug('------------- contactSize: ' + results.size() );
        return results;

    // per the current matrix, load the booleans for the contact's assets values
    public List<serviceWrapper> getOriginalServices() {
              List<serviceWrapper> results = new List<serviceWrapper> ();
              List<Services__c> serviceGrid = new List<Services__c>();
                serviceGrid = [ SELECT sv1.Account_Name__c, sv1.Asset__c, sv1.Contact__c, Case__c, Active__c
                                from services__c sv1 
                                where sv1.Account_Name__c = :acct.Name and
                                sv1.isDeleted = false
                                order by sv1.Case__c desc ];
          system.debug('------------- contactSize: ' + contactList.size() );
          system.debug('------------- assetSize: ' + assetList.size() );
          system.debug('------------- serviceGridSize: ' + serviceGrid.size() );
            for (contact con1 : contactList) {
            for (assetWrapper asw : assetList ) {
              boolean sel1 = false;  
              Asset as1 = asw.ast;
              for (Services__c svw : serviceGrid ) {
                if (svw.Asset__c == asw.ast.id ) {
                  if (svw.Contact__c == con1.id) {
                    sel1 = svw.Active__c;
              results.add(new serviceWrapper(as1,con1,sel1));
          return results;

    // getService/serviceList - used to store the result of each asset/contact checkbox 

    public Boolean ServiceDetail() {
      system.debug('------------- getServices: assetId:' + assetId+ '/contactId' + contactId );
      boolean results = false;
      for (serviceWrapper svw : changedList ) {
          if (svw.ast.id == assetId) {
              if (svw.con.id == contactId ) {
                  results = svw.selected;
        return results;

    // assetWrapper - used to hold the boolean/checkbox selection for the account, for the asset-select-all  
    public class assetWrapper {  
        public Asset ast{get; set;}
        public Boolean selected {get; set;}  
        public assetWrapper(Asset b, Boolean sel)  {  
            ast  = b;
            if (selected == null ) {
              selected = false;
            } else {
                selected = sel;
    // serviceWrapper - wrapper class to hold the boolean/checkbox for the matrix detail
    public class serviceWrapper {  
        public Asset ast{get; set;}
        public Contact con{get; set;}  
        public Boolean selected {get; set;}  
        public Boolean Original_selection {get; set;}  
        public serviceWrapper(Asset b, Contact c, Boolean sel)  {  
            ast = b;
            con = c;
            if (selected == null ) {
                selected = false;
            }  else {
                selected = sel;
            Original_selection = selected;  
    public PageReference Save() {
        string strOrig =  parseList(OriginalservicesList);
        string strChanged =  parseList(ChangedList);
        system.debug('------------- Save: (orig) ' + strOrig);
        system.debug('------------- Save: (new)  ' + strChanged);
        return null;


Our production deployments using the (ant) force migration tool have been consistently failing recently, after executing some percentage of our tests, with the error:

System.LimitException: Your runAllTests request is using too many DB resources.

All of our tests are @isTest(seeAllData=false) and we recreate all test data from scratch using factory classes at the beginning of each test method.

We contacted Salesforce support, and after a multiple calls, different people, and a lot of time, they told us that in addition to the per-transaction governor limits, there are undocumented limits that are shared amongst all executed code during the course of a runAllTests request:
  • The DML statement limit is 350,000
  • The SOQL statement limit is 450,000
Salesforce suggested that we use the @testSetup annotation to setup data in our tests (we have not been using that annotation), and this would help us in avoiding hitting the above limits. I wrote a small unit test to verify that this would actually help with limits, but the unit test suggests that the DML statements accrued in a @testSetup annotated method do indeed count in each testmethod.
public class TestSalesforceTestSetupDMLCount {

    @testSetup static void setup(){
        // Assert that no DMLs have occurred yet
        system.assertEquals(0, Limits.getDMLStatements());
        // Perform 4 DMLs
        for(Integer i=0; i<4; i++){
            insert new Account(Name='Test' + i);
        // Assert that 4 DMLs have been performed
        system.assertEquals(4, Limits.getDMLStatements());
    public static testmethod void testDmlCount1(){
        system.assertNotEquals(4, Limits.getDMLStatements());
    public static testmethod void testDmlCount2(){
        system.assertNotEquals(4, Limits.getDMLStatements());

The 2 testmethods fail because Limits.getDMLStatements() returns 4. The question is, regarding the runAllTests DML statement limit of 350,000, does the above test contribute 4 DML statements or does it contribute 12 DML statements (4 for setup(), 4 for testDmlCount1(), 4 for testDmlCount2())?

This is obviously something that only Salesforce can answer, but I at least want this issue documented somewhere, and will provide updates as we get answers from Salesforce.
How do you create formulas similar to the excel formulas listed below in Salesforce?

Excel Example
I am collecting LOVs from a picklist in a map.

If value==ABCD, replace it with BCDE

Please  help with the replace syntax

We recently refreshed a sandbox and now when trying to pull down classes into the IDE, we are unable to.  The classes folder is empty.  Other sandboxes seem fine.  There are definitely classes in there.

Any ideas?



Hi friends,


I have list of records,when i click the particular records it display the details of records.some records not display it's loading too long time after that am getting err like this.. Apex CPU time limit exceeded and An unexpected error has occurred. Your development organization has been notifiedwhy this err occur how to resolve this please can anyone help me..thanks in advance..





I created two methods in this class but when saved generates this error message. "Save Error: Entity is not org-accessible"


Is a test method. I'm using isTest(SeeAllData=true) annotation.


So happens when I try to add two more methods class.

Anyone know what can be?





Diego Moreira

I utilize Conga Merge to produce many printable documents throughout the standard and custom objects.  To access the Conga Merge functionality, I'd like to pass the variables from my flow into a link on a flow screen.  The screen element has the ability to create a hyperlink; however, the variables are not recognized within this link.  The link is simply a static link.  Is there any way within any of the flow elements to create a dynamic link?


The link would look something like this:




I would pass in the Session Id, API.PartnerServer URL, and Opportunity Id, and some additional report filter criteria.


I realize that I can pass these variables to the closing visual force page and make the button/links available there.  However, I'd prefer to have the links available within the flow.

Hi All,


I want to access email name, email address and automatic BCC fields of My Email Settings in my apex class. Please suggest me some solution to do this.






I have developed a daily poll component for the force.com based site.


I have used customer portal to authenticate users.

I have added that component within the right hand template.

<apex:component allowDML="true" controller="cybVotePoll" id="Poll">

<apex:pageBlock title="Today's&nbsp;Poll" id="PollPageBlock" mode="edit">

<apex:panelgrid id="Graph" columns="1">

<apex:outputLabel value="{!PollQuestion}"style="font-size:12px;font-style:italic;color:#0000ff;font-weight:bold;" />

<apex:outputLabel value="{!Msg}" style="color:#ff0000;" id="msg" />

<apex:form >

<apex:selectRadio value="{!UserVote}" id="ResponsePanel" disabled="{!DisableOptions}">

 <apex:selectOptions value="{!ResponseOptions}" />

<apex:actionSupport event="onclick" action="{!SubmitVote}"rerender="ResponsePanel,msg,OutputResult" status="test" />



<apex:actionStatus id="test" startText="submitting vote..." />

<apex:image width="200" height="150" url="{!ResponseUrl}"id="OutputResult" />

<apex:form >

<apex:commandLink action="{!showPastResults}"value="Past Results >>" />






Whenever the radio option is selected on the page, it shows error page with error as insufficient privilege.

I have removed all ther crud rights from the profile so that user could not get access to salesforce standard pages.

Please any one guide me on this issue.

Hi All,


I want to send an email with an Attachment from Notes and Attachment related list.


i.e. i have few attachments inside Notes and Attachment related list of a custom Object.. and on a button click i need to send an email with attachment


please let me kow how can i do that...






I know this is a silly question, but i am not able to see the image when i call a static resource image in to visualforce using <img> tag. This is what i am using right now, and the picture is not appearing in the VF Page,  i just see a cross mark instead of the picture.


<img src="{ !$Resource.image_TwitterIcon }" />


I have the above individual picture  in static resources. Can any one suggest a way to fix this.



  • May 19, 2010
  • Like
  • 0

I have used the same code as provided for exporting in my application.In Windows the excel gets exported in a proper manner but when I try to export in MAC OS I get the code written inside the script tag from Salesforce's side.Here is the gibberish code that I get


if(!window.sfdcPage){window.sfdcPage = new ApexPage();}
UserContext.initialize({'isAccessibleMode':false,'ampm':['AM','PM'],'locale':'en_US','dateTimeFormat':'M/d/yyyy h:mm a','today':'1/28/2009 2:37 AM','dateFormat':'M/d/yyyy','language':'en_US','siteUrlPrefix':'','userPreferences':[{'value':false,'index':119,'name':'HideUserLayoutStdFieldInfo'}


Is this a SalesForce bug or an error from our side.If it is an error do I need to log a bug?? 

Has anyone wrote a null replacement apex method for strings? I keep getting the error, attempting to dereference null. Similar in behavior to the formula NULLVALUE(expression, substitute_expression).
In this example I am concatenating a contact first and last name together. But the first name is often null. the string then becomes null lastname instead of just last name
I have a text formula to which I would like to add a carriage return/line break.  I tried concatenating chr(13) and chr(10), but the validation didn't like it.  Is this possible?