• ppoojary18@gmail.com
  • 5 Points
  • Member since 2014

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 7

In my controller i have one getter,setter variable.
public boolean test {get;set;}
public void next(){
test = true;
In page i have one button 
<apex:commandbutton value="Next" action = "{!Next()}" />
This will call component alse

In component 
<apex:attribute name="extrapoints" type="Boolean" description="extrapoints" assignTo="{!test}" />
<apex:outputText value ="{!test}"
If i debug the component i am getting false value.But i need here true.

Can any one help on this

Hey there,

I have validation rules on my custom object service__c. Service__c, has a visualforce page for creating new services. Whenever a validation rule is triggered however, rather than the error appearing on te page in error, with no re-direction...it is re-directed to another page, which is all white, with black writing that says:

Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION

How can I make the errors appear on the visualforce page without re-direction? If it helps, I have made all the buttons custom.

I have already added <apex:pagemessages/> to the top of the page.

please Help
This is my scenario, i have the following VF page, i need to get the value of Cantidad in my controller so i can update the quantity selected by the user:
<apex:page action="{!init}" controller="mainControllerV2" showHeader="false" standardStylesheets="true">

<apex:outputPanel id="the_outputpanel2">
    <apex:pageBlock >
    <p>Paso #4 - Agregue los productos a la factura.</p>
      <apex:form >
        <apex:pageBlockTable id="srch_id" value="{!ListaSRCH}" var="o">
            <apex:column value="{!o.CantidadExistencia__c}"> <apex:facet name="header"> </apex:facet>
            <apex:inputField value="{!o.CantidadExistencia__c}"/>
            <apex:column value="{!o.Codigo__c}"> <apex:facet name="header"> </apex:facet> </apex:column>
            <apex:column value="{!o.Descripcion__c}"> <apex:facet name="header"> </apex:facet> </apex:column>
            <apex:column value="{!o.Precio__c}"> <apex:facet name="header"></apex:facet> </apex:column>
            <apex:column headerValue="Opciones" >
                    <apex:commandLink value="AGREGAR" action="{!add2carrito}">
                            <apex:actionSupport event="onclic" rerender="the_outputpanel3"/>    
                            <apex:param name="idz"   assignTo="{!current_prod}" value="{!o.id}"  />                               

Im not sure whats the value of value="{!o.CantidadExistencia__c}" im pretty new to apex i dont know what variable it references to.

This is my controllers methods:

public List<Producto__c> getListaSRCH(){
Operaciones O = new Operaciones();
//ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Error al buscar'));
return O.busqueda(STR_SRCH);

public PageReference add2carrito(){
//se tiene el id
//Producto__c P = new Producto__c();

  Producto__c P =[select id, Name, Precio__c, Codigo__c, Tipo__c,CantidadExistencia__c, Descripcion__c from Producto__c where id=:current_prod limit 1];
   if (P.CantidadExistencia__c != 0) {
    P.CantidadExistencia__c = 1;
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'El item :'+ P.Descripcion__c + ' se encuentra agotado en el inventario.'));
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'El item :'+ P.Descripcion__c +' no tiene existencias en el inventario. Asegurese de ingresar existencia antes de facturar.'));
catch(exception j){ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Error al agregar elemento al carrito'+j));}
return null;

public Integer is_present(Producto__c P){
  Integer counter = 0;
  Integer answ = 0;
  boolean present = false;
  for( Producto__c C : CARRITO){
    if(C.Codigo__c == P.Codigo__c){answ = counter;present=true;}
    else{counter ++;}
  return answ;

public void insertarLinea()
        List<Linea__c> lines = new list<Linea__c>(); // crea una lista con las lineas de la factura
            //Para cada producto C en carrito
            for(Producto__c C : CARRITO) {

                   Linea__c Line = new Linea__c ();
                   Line.Cantidad__c = C.CantidadExistencia__c;
                   Line.Factura__c = current_factura.id;                 
                   Line.Monto_Colones__c = C.Precio__c;
                   Line.Monto_Dolares__c = 0;
                   Line.Producto__c = C.id;
                   lines.add(Line); // adding line to list
                 Producto__c P =[select id, CantidadExistencia__c from Producto__c where id=:C.id limit 1];
                 P.CantidadExistencia__c = P.CantidadExistencia__c - Line.Cantidad__c;         
                 update (P);                        


            insert (lines); // Insertamos la lista lineas asi evitamos hacer un insert por cada registro que haya en CARRITO
        catch(Exception a)
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Error al insertar la linea. '+a));


How can i proceed any ideas, suggestions, i have tried sending the value through apex:param but i dont really knew how to proceed i have been stucked with this for 3 days know.

Thank you 

 Visulaforce and Controller which i have created is conditionally SOQL I tried few methods which posted in few blogs but i couldnt sucess.

 In controller I am limiting query to display only 10 records for now. But there are more than 1000k records. Please suggest me how to achive pagination on my requirement. 


public class Renwal_Account_test
  //URL Passing Parameters.
  String PageContractId = ApexPages.currentPage().getParameters().get('ContractId');    
  String PageAccountId  = ApexPages.currentPage().getParameters().get('AccountId');  
  //Our collection to class/wrapper objects wrapAsset
  public List<wrapAsset> wrapAssetList {get; set;}
  public List<Asset> selectedAssets{get;set;}    
  public Renwal_Account_test()
   GetAccount = new Asset();    //Get Account Id from Page
   GetContract = new Asset();   //Get Contract Name from Page  
  public Asset GetAccount{get;set;}
  public Asset GetContract{get;set;}
  public List<Asset> Account_yourObjList{get;set;}
  public List<Asset> Asset_yourObjList{get;set;}  
  public List<Asset> Default_Asset_yourObjList{get;set;} 
  //Function to Return Asset Report Passing Account ID   
  public void Filter_Account_Records(){
    Account_yourObjList = new List<Asset>();
  If ( GetAccount.AccountId == NULL || GetContract.Name == NULL )
    If ( PageContractId <> NULL )
      Contract C;
      C = [SELECT Name FROM Contract WHERE Id = :PageContractId Limit 1];
      Account_yourObjList = [SELECT Id,AccountId,Product2Id,SerialNumber,last_contract_number__c,Service_Start_Date_Min__c, Service_End_Date_Max__c,InstallDate from Asset WHERE last_contract_number__c = :C.Name LIMIT 10];                      
    else If ( PageAccountId <> NULL )
      Account_yourObjList = [SELECT Id,AccountId,Product2Id,SerialNumber,last_contract_number__c,Service_Start_Date_Min__c, Service_End_Date_Max__c,InstallDate from Asset WHERE AccountId = :PageAccountId LIMIT 10];                        
  If ( GetAccount.AccountId <> NULL && GetContract.Name == NULL )
    Account_yourObjList = [SELECT Id,AccountId,Product2Id,SerialNumber,last_contract_number__c,Service_Start_Date_Min__c, Service_End_Date_Max__c,InstallDate from Asset WHERE AccountId = :GetAccount.AccountId LIMIT 10];                      
  else If ( GetContract.Name <> NULL && GetAccount.AccountId == NULL )
    Account_yourObjList = [SELECT Id,AccountId,Product2Id,SerialNumber,last_contract_number__c,Service_Start_Date_Min__c, Service_End_Date_Max__c,InstallDate from Asset WHERE last_contract_number__c  = :GetContract.Name LIMIT 10];                      
  else If ( GetAccount.AccountId <> NULL && GetContract.Name <> NULL )
    Account_yourObjList = [SELECT Id,AccountId,Product2Id,SerialNumber,last_contract_number__c,Service_Start_Date_Min__c, Service_End_Date_Max__c,InstallDate from Asset WHERE AccountId = :GetAccount.AccountId and last_contract_number__c = :GetContract.Name LIMIT 10];
   // Selection of Row to Temp Collection
   //if(wrapAssetList == null) {
     wrapAssetList = new List<wrapAsset>();
       for(Asset a: Account_yourObjList) {
        wrapAssetList.add(new wrapAsset(a));       
          //  }   
  // Store Selected Records to Object/Table
public void processSelected() {
    selectedAssets = new List<Asset>();
    list<Temp_Assets__c> TempAssetList = new list<Temp_Assets__c>();
        for(wrapAsset wrapAssetObj : wrapAssetList) {
            if(wrapAssetObj.selected == true) {                              
       for(Asset Act : selectedAssets)
              Temp_Assets__c TempAsset = new Temp_Assets__c();
              TempAsset.Name = 'Sudhir';
              TempAsset.AccountId__c = Act.AccountId;
              TempAsset.Product__c = Act.Product2Id;
              TempAsset.Serial_Number__c = Act.SerialNumber;
              TempAsset.Last_Contract_Number__c = Act.last_contract_number__c;
              TempAsset.Service_Start_Date__c = Act.Service_Start_Date_Min__c;
              TempAsset.Service_End_Date__c = Act.Service_End_Date_Max__c;
              TempAsset.Install_Date__c = Act.InstallDate;                           
        Insert TempAssetList;
    // This is our wrapper/container class.
    public class wrapAsset {
        public Asset acc {get; set;}
        public Boolean selected {get; set;}

        public wrapAsset(Asset a) {
            acc = a;
            selected = false;



<apex:page title="Renewal Quote" controller="Renwal_Account_test" showHeader="false" sidebar="false" readOnly="false" cache="false">

<script type="text/javascript">
        function selectAllCheckboxes(obj,receivedInputID){
            var inputCheckBox = document.getElementsByTagName("input");
            for(var i=0; i<inputCheckBox.length; i++){
                    inputCheckBox[i].checked = obj.checked;
<apex:sectionHeader subtitle="Create Renewal Quote" title="Meru Networks"/>

<apex:form >
<apex:pageBlock >
<apex:pageBlockSection title="Filters" columns="2">
<apex:inputField value="{!GetAccount.AccountId}"/>
<apex:commandButton action="{!Filter_Account_Records}" value="Fetch Data"></apex:commandbutton>
<apex:inputField value="{!GetContract.Name}" required="false"/>

<apex:form >
        <apex:pageBlock id="details" >
            <apex:pageBlockButtons >
                <apex:commandButton value="Save Records" action="{!processSelected}" rerender="table2"/>

            <apex:pageblockSection title="Install Base Report" collapsible="false" columns="1">

                <apex:pageBlockTable value="{!wrapAssetList}" var="accWrap" id="table" title="All Accounts">
                    <apex:column >
                        <apex:facet name="header">
                            <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
                        <apex:inputCheckbox value="{!accWrap.selected}" id="inputId"/>
                    <apex:column value="{!accWrap.acc.AccountId}" />
                    <apex:column value="{!accWrap.acc.Product2Id}" />
                    <apex:column value="{!accWrap.acc.SerialNumber}" />
                    <apex:column value="{!accWrap.acc.last_contract_number__c}" />
                    <apex:column value="{!accWrap.acc.Service_Start_Date_Min__c}" />
                    <apex:column value="{!accWrap.acc.Service_End_Date_Max__c}" />
                    <apex:column value="{!accWrap.acc.InstallDate}" />                   
                 <apex:pageBlockTable value="{!selectedAssets}" var="c" id="table2" title="Selected Assets">
                    <apex:column value="{!c.AccountId}" headerValue="Account Name"/>
                     <apex:column value="{!c.Product2Id}" headerValue="Product" />
                    <apex:column value="{!c.SerialNumber}" headerValue="Serial Number"/>  
                    <apex:column value="{!c.last_contract_number__c}" headerValue="Last Contract Number"/>
                    <apex:column value="{!c.Service_Start_Date_Min__c}" headerValue="Service Start Date" />
                    <apex:column value="{!c.Service_End_Date_Max__c}" headerValue="Service End Date"/>
                    <apex:column value="{!c.InstallDate}" headerValue="Install Date" />                


I want to show opportunity fields on Force.com and also update an opportunity from force.com sites..

When i am using apex:input fields the fields are not showing in input mode.When i use inputtext it works.My problem is about date fields it comes as a inputtext and dateselector doesn't come.

Now i also want to update the opportunity record.I have found that we can't update standard object.I have found one link where it says if you use without sharing then you can update. Workarounds for Sites page to update standard object?

But i am not able to do it.Please help in this.Its really very urgent for me.

VF page

<apex:page controller="oppDetailUsersCntlr"  showHeader="false" cache="false" >
<apex:form >
<apex:sectionHeader title="Opportunity" subtitle="Detail"/>
<apex:pageBlock mode="inlineEdit" rendered="{!editSection}">
     <apex:pageBlockButtons >
         <apex:commandButton value="Save" id="saveButton" action="{!saveOpp}"/>
         <apex:commandButton value="Edit" id="editButton" action="{!editOpp}"/>
     <apex:pageBlockSection columns="2">
         <apex:inputText value="{!opp.name}"/>
         <apex:inputField value="{!opp.closedate}"/>
         <apex:outputField value="{!opp.accountid}"/>
         <apex:inputText value="{!opp.Probability}"/>


public void saveOpp()

Opportunity o=new opportunity(id=id);
update o;