• Jai Prakash Gupta
  • NEWBIE
  • 9 Points
  • Member since 2015


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 4
    Replies
Hi All,

I am new to coding and I have created a VF page with wrapper class and I want to count no of check box seleted.

VF Page:
<apex:page controller="myController2" sidebar="false">
      <apex:form >
         <apex:pageBlock >
           
            <apex:pageBlockTable value="{!Pubs}" var="p" id="table">
                <apex:column >
                    <apex:inputCheckbox value="{!p.selected}" onchange="updateSelectCount(this);"/>
                </apex:column>
                <apex:column value="{!p.con.Name}" />
                <apex:column value="{!p.con.Type__c}" />
                <apex:column value="{!p.con.Circulation__c}" />
                  
            </apex:pageBlockTable>
              
        </apex:pageBlock>
    </apex:form>
      
</apex:page>

Class:
public class myController2 {
 public list<pPublication> mypub{set;get;}
  public List<pPublication> getPubs() {
        if(mypub == null) {
            mypub = new List<pPublication>();
            for(Publication__c p: [select id,name,Circulation__c,Hit_Rate__c,Type__c from Publication__c limit 10 ]) {
                mypub.add(new pPublication(p));
            }
        }
        return mypub;
    }
    public PageReference processSelected() {
    List<Publication__c> selectedPubs = new List<Publication__c>();
    for(pPublication cPub: getPubs()) {
            if(cPub.selected == true) {
                selectedPubs.add(cPub.con);
                
            }
        }
       for(Publication__c con: selectedPubs) {
            system.debug(con);
        }
        mypub=null;
        return null;
        }
        public class pPublication {
        public Publication__c con {get; set;}
        public Boolean selected {get; set;}
                public pPublication(Publication__c p) {
            con = p;
            selected = false;
      }

}
     }

I am not able to count the selected checkboxes.

Please help.

Thanks in advance!!
Hi All,

I am new to coding and I have created a VF page with wrapper class and I want to count no of check box seleted.

VF Page:
<apex:page controller="myController2" sidebar="false">
      <apex:form >
         <apex:pageBlock >
           
            <apex:pageBlockTable value="{!Pubs}" var="p" id="table">
                <apex:column >
                    <apex:inputCheckbox value="{!p.selected}" onchange="updateSelectCount(this);"/>
                </apex:column>
                <apex:column value="{!p.con.Name}" />
                <apex:column value="{!p.con.Type__c}" />
                <apex:column value="{!p.con.Circulation__c}" />
                  
            </apex:pageBlockTable>
              
        </apex:pageBlock>
    </apex:form>
      
</apex:page>

Class:
public class myController2 {
 public list<pPublication> mypub{set;get;}
  public List<pPublication> getPubs() {
        if(mypub == null) {
            mypub = new List<pPublication>();
            for(Publication__c p: [select id,name,Circulation__c,Hit_Rate__c,Type__c from Publication__c limit 10 ]) {
                mypub.add(new pPublication(p));
            }
        }
        return mypub;
    }
    public PageReference processSelected() {
    List<Publication__c> selectedPubs = new List<Publication__c>();
    for(pPublication cPub: getPubs()) {
            if(cPub.selected == true) {
                selectedPubs.add(cPub.con);
                
            }
        }
       for(Publication__c con: selectedPubs) {
            system.debug(con);
        }
        mypub=null;
        return null;
        }
        public class pPublication {
        public Publication__c con {get; set;}
        public Boolean selected {get; set;}
                public pPublication(Publication__c p) {
            con = p;
            selected = false;
      }

}
     }

I am not able to count the selected checkboxes.

Please help.

Thanks in advance!!
This is the Challenge:

To pass this challenge, create an Apex class that inserts a new account named after an incoming parameter. If the account is successfully inserted, the method should return the account record. If a DML exception occurs, the method should return null.The Apex class must be called 'AccountHandler' and be in the public scope.
The Apex class must have a public static method called 'insertNewAccount'.
The 'insertNewAccount' method must accept an incoming string as a parameter, name the account after the parameter, insert it into the system and then return the account record.
The 'insertNewAccount' method must also accept an empty string, catch the failed DML and return null.


My Class:

public class AccountHandler {

    public static Account insertNewAccount (String accName, Account a) {
         try{   
          a.name = accName;
    
         insert a;
        return a;
        }
        catch(Exception e) {
            return null;
        }
    }    
}



User-added image


Throwing this error, how many times i modified the class.
what is the correct class.?
 
Hello everyone,

I have an Account table with a custom field with data type 'Picklist'.
What I want to do is, for each record in the account table I want the picklist value and also the label for that value.

Due to some limitations I can't execute the simple query ...
SELECT Custom_Field_1__c, toLabel(Custom_Field_1__c) FROM Account"

When I execute that query I get the error ...
INVALID_FIELD:
SELECT UCB_Specialty_1__c, toLabel(UCB_Specialty_1__c) FROM Account
^
ERROR at Row:1:Column:36
duplicate field selected: UCB_Specialty_1__c ].
caused by: AxisFault

If anyone knows a work around or a solution, I'd appreciate to hear about it.
Thank you.

Greetings,

Hamid