• ❤Code
  • NEWBIE
  • 190 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 5
    Likes Received
  • 0
    Likes Given
  • 182
    Questions
  • 115
    Replies
Hi All,

Does anyone has any example for shopping cart / Add to cart functionality. Please share.

Regards
Hi All,

Can anyone tell me how to insert dynamically created dates fields from vf page. 

Below is a sample from jsfiddle.

http://jsfiddle.net/swm53ran/331/

Regards
Can anyone provide some idea or approach on how to create a multiselect picklist like below pic.User-added image

Regards
Hi All,

Can anyone help me out creating a test class for the below class - 
 
public class SMI_overrideCon {
   String recordId;
   
public SMI_overrideCon (ApexPages.StandardController 
       controller) {recordId = controller.getId();}

public PageReference redirect() {
  Profile p = [select name from Profile where id = :UserInfo.getProfileId()];
  //String standardp = 'https://cs59.salesforce.com';
  if (!'System Administrator'.equals(p.name) ) 
      {
       PageReference customPage =  Page.customSMIPage;
       customPage.setRedirect(true);
       customPage.getParameters().put('id', recordId);
       return customPage;
      } else {
      
         return new PageReference('/' + recordId +  '?nooverride=1');
    
      }
   }
}

 
I am trying the below code to add field history as a related list of opportunity in vf page, but its not working .
 
<apex:relatedList list="OpportunityFieldHistory"/>


Can anyone tell me what is the correct way to write it.
Regards
 
Hi All,

I am using the below code for validating email address using jquery.
I need to validate zipcode using jquery for US only. How can I do it using jquery library.
Can anyone help me with this.
 
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>My Page</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css">
    <script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
    <script src="https://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.15.0/jquery.validate.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.15.0/jquery.validate.js"></script>
    <style>
    label.error {
        color: red;
        font-size: 16px;
        font-weight: normal;
        line-height: 1.4;
        margin-top: 0.5em;
        width: 100%;
        float: none;
    }
    @media screen and (orientation: portrait) {
        label.error {
            margin-left: 0;
            display: block;
        }
    }
    @media screen and (orientation: landscape) {
        label.error {
            display: inline-block;
            margin-left: 22%;
        }
    }
    em {
        color: red;
        font-weight: bold;
        padding-right: .25em;
    }
    </style>
</head>
<body>
<div id="page1" data-role="page">
    <div data-role="header">
        <h1>Welcome</h1>
    </div>
    <div data-role="content">
        <form method="GET">
            <div data-role="fieldcontain">
                <label for="email">Email:</label>
                <input type="email" name="email" id="email">
            </div>
            <div data-role="fieldcontain">
                <label for="password">Password:</label>
                <input type="password" name="password" id="password">
            </div>

            <div data-role="fieldcontain">
                <label for="zip">Zipcode:</label>
                <input type="text" name="zip" id="zip">
            </div>


            <input data-role="submit" type="submit" value="Login">
        </form>
    </div>
</div>

<script>
$( "#page1" ).on( "pageinit", function() {
    $( "form" ).validate({
        rules: {
            email: {
                required: true
            },
            password: {
                required: true
            }
        },
        errorPlacement: function( error, element ) {
            error.insertAfter( element.parent() );
        }
    });
});
</script>
</body>
</html>

Regards
 
I have an issue here. I have an object O1 and a field F1. Field F1 is getting updated when an record is created in another object O2 by a trigger running on object O1.
Field F1 cannot be edited by inline.
There is are validtions rules on object O1.
I need when i create a record in object O2 all the validation rules in O1 should get by passed and field F1 should get updated.
But when an user does an inline edit on a record present in object O1 the validation rule should fire.

To achieve this i am making the custom setting to true and in the validation rule i am using like below - 
 
​( $Setup.ByPassvalidation__c.Bypassrules__c ) && (TODAY() > PRIORVALUE(CloseDate))

This is working fine when i am inserting record in object O2. But if a user does an inline edit in object O1 the validation rule is not wokring.

Can anyone tell how to make this work.
I am facing a issue while cheking the below page in mobile and desktop.The captcha part
 
`<div class="g-recaptcha" data-sitekey="6LcahyITAAAAAOjQ8U5d9i62LBgQkjEeLrUDABOX" data-callback="onSuccess()" ></div>`
is not getting properly aligned when seen in mobile and desktop.
Can anyone help me how to make it align properly both in desktop and mobile.
 
<!DOCTYPE html>
    <html lang="en">
    <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
    <title>Hello</title>
    <meta content="width=device-width, initial-scale=1" name="viewport">
    <meta content="IE=edge" http-equiv="X-UA-Compatible">
    <meta charset="utf-8">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
    <script src="http://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.js"></script>
    <script src='https://www.google.com/recaptcha/api.js'></script>
    </head>

    <body style="background: #f2f2f2;">
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <div style="position: relative; width:95%; max-width: 820px; height: 467px; background: #ffffff; font-family:Arial, Helvetica, sans-serif; margin:0px auto;">
      <div style=" position:absolute; left:0px; top:50px; width:100%; text-align:center;">  </div>
      <div style="position:absolute; left:0px; top:160px; width:100%; font-size:24px; text-align:center; font-weight:bold;"> Hello </div>
      <div style="position:absolute; left:0px; top:180px; width:100%; font-size:16px; text-align:center;"> <br>
        Get the smartest tips, news and tools on parenting in one timesaving newsletter, plus more.<br>
        <a href="http://google.com/" style="color:#e2232e; font-size:14px; text-decoration:none; white-space:nowrap;" target="_blank">See Sample</a><br>
        <br>
        <br>
      </div>
      <form   method="post" style="position:absolute; left:0px; top:290px; width:100%; font-size:18px; text-align:center;" onsubmit="return validateCapcha();">

        <input value="" class="newsletter-email-text" style="vertical-align:middle; width:55%; max-width:250px; height:30px; padding:2px 3px; border:1px solid #dddddd; font-size:18px; background:#ffffff;" name="email" type="text" pattern="[A-Za-z0-9._+-]{3,}@[a-zA-Z]{3,}([.]{1}[a-zA-Z]{2,}|[.]{1}[a-zA-Z]{2,}[.]{1}[a-zA-Z]{2,})" placeholder="Email" title="Valid email address required" required>
        <input value="SUBMIT" class="newsletter-email-submit-button" style="vertical-align:middle; width:95px; height:36px; line-height:36px; text-align:center; background:#ed1c24; color:#ffffff; border:0px; border-radius:3px; font-weight:bold; font-size:14px; cursor:pointer;" type="submit">

        <div style="position: relative; width:95%; max-width: 820px; height: 467px;  font-family:Arial, Helvetica, sans-serif; margin:0px auto;">
        <div class="g-recaptcha" data-sitekey="6LcahyITAAAAAOjQ8U5d9i62LBgQkjEeLrUDABOX" data-callback="onSuccess()" ></div>
        </div>
        <p id="customeMessage" style="display:none;position:absolute;bottom:10px;vertical-align:middle;text-align:center;top:112px;left:229px;"><lable> Please check the capcha </lable></p>


      </form>

    </div>

    </body>
    </html>


I want google captcha div tag should be align with email input box.

Regards
Hi All,

Does anyone have any idea how to implement google recaptcha in exacttarget microsites using ampscript or javascript.

Regards
I am trying to do pagination. But it is not working. Can anyone let me know where i am wrong -
Below is the apex class -
 
public with sharing class wrapper_test_controller {
public list<wrapperclass> wrapperelement_for_account{get;set;}
public list<wrapperclass> wrapperelement_for_contact{get;set;}
public string selectedproductfamily {get;set;}
    public String qryString;

    private integer totalRecs = 0;
private integer OffsetSize = 0;
private integer LimitSize= 2;
public list<product2> queryResult{get;set;}

    public Work_Order_Item__c service1 {get;set;}

public List<SelectOption> getproductfamily(){

}

    public PageReference query() {
    system.debug('@@@'+selectedproductfamily);


        if(selectedproductfamily!='Any Type'){
         qryString = 'SELECT Id,name,family,Measurement_Type__c,Cleaning_Unit_Price__c,Treatment_Unit_Price__c,(select Service__c,Quantity__c,Length__c,Width__c from work_order_items__R) FROM product2 WHERE ' +

            '(Family like \'%' + selectedproductfamily + '%\')';
        }else{

         qryString = 'SELECT Id,name,family,Measurement_Type__c,Cleaning_Unit_Price__c,Treatment_Unit_Price__c,(select Service__c,Quantity__c,Length__c,Width__c from work_order_items__R) FROM product2';

        }
        queryResult = Database.query(qryString);

        return null;

    }

    public wrapper_test_controller (ApexPages.StandardController controller) {


 }



//
public void FirstPage()
{
OffsetSize = 0;
query();
}
public void previous()
{
OffsetSize = (OffsetSize-LimitSize);
query();
}
public void next()
{
OffsetSize = OffsetSize + LimitSize;
query();
}
public void LastPage()
{
OffsetSize = totalrecs - math.mod(totalRecs,LimitSize);
query();
}
public boolean getprev()
{

if(OffsetSize == 0){

return true;
}
else {

return false;
}
}
public boolean getnxt()
{
if((OffsetSize + LimitSize) > totalRecs){

return true;
}
else {

return false;
}
}
//////    


}

 
I have a pageblocktable like below

User-added image

The column from Product to Treatment Unit Price are the fields from Product2. Column from Service to Width are the fields from Object WorkOrderItem__c.
WorkOrderItem__c is a related list to Product2.
I want if there are no WorkOrderItem__c records for a Product2, fields should appear. Not it is showing notthing on vf page if there are no records. Below is the class and vf page -
 
public with sharing class wrapper_test_controller {
public list<wrapperclass> wrapperelement_for_account{get;set;}
public list<wrapperclass> wrapperelement_for_contact{get;set;}
public string selectedproductfamily {get;set;}
public list<product2> queryResult{get;set;}
public list<Work_Order_Item__c> queryResult1{get;set;}

public List<SelectOption> getproductfamily(){
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('None', 'None'));
        options.add(new SelectOption('Bedding', 'Bedding'));
        options.add(new SelectOption('Flooring', 'Flooring'));
        options.add(new SelectOption('Seating', 'Seating'));
        options.add(new SelectOption('Wall Treatments', 'Wall Treatments'));
        options.add(new SelectOption('Other', 'Other'));

        return options;
}

    public PageReference query() {
    system.debug('@@@'+selectedproductfamily);

       // String qryString = 'select Product__r.IsActive ,Product__r.Measurement_Type__c,Product__r.Treatment_Unit_Price__c,Product__r.Cleaning_Unit_Price__c,Product__c,Product__r.Name,Product__r.Family,id,name,Service__c,Quantity__c,Length__c,Width__c from Work_Order_Item__c WHERE ' +

         //   '(Product__r.Family like \'%' + selectedproductfamily + '%\')';

         String qryString = 'SELECT Id,name,family,Measurement_Type__c,Cleaning_Unit_Price__c,Treatment_Unit_Price__c,(select Service__c,Quantity__c,Length__c,Width__c from work_order_items__R) FROM product2 WHERE ' +

            '(Family like \'%' + selectedproductfamily + '%\')';

        queryResult = Database.query(qryString);

        return null;

    }

//list<Product2> object1 = [select id,name,Family,Measurement_Type__c,Treatment_Unit_Price__c,Cleaning_Unit_Price__c from Product2 limit 10];
//list<Work_Order_Item__c> object2 = [select Product__r.Measurement_Type__c,Product__r.Treatment_Unit_Price__c,Product__r.Cleaning_Unit_Price__c,Product__c,Product__r.Name,Product__r.Family,id,name,Service__c,Quantity__c,Length__c,Width__c from Work_Order_Item__c limit 10];

public wrapper_test_controller (ApexPages.StandardController controller) {

 }

public list<wrapperclass> getPieData() {
 List<wrapperclass> data = new List<wrapperclass>();


 AggregateResult[] groupedResults  = [SELECT  Product__r.Family f,count(Id) c
        FROM Work_Order_Item__c
        WHERE Product__r.Family != null
        GROUP BY Product__r.Family];

 for (AggregateResult ar : groupedResults)  {            

                    data.add(new wrapperclass(String.ValueOf(ar.get('f')),Integer.ValueOf(ar.get('c'))));

             } 

             return data; 

}
public class wrapperclass{
public String name { get; set; }  
public Integer data { get; set; }  
public Product2  account {get;set;}
public Work_Order_Item__c service {get;set;}

public wrapperclass(String Name,Integer data) {
this.name = Name; 
  this.data = data;
 } 
public wrapperclass (Work_Order_Item__c record){
  this.service = record;


  }


}
}
 
<apex:page standardController="Work_Order__c" extensions="wrapper_test_controller">

    <apex:form >

        <apex:pageblock id="pb">

                <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save" />
                <apex:commandButton action="{!Cancel}" value="Cancel" />
                 </apex:pageBlockButtons >

        <apex:pageblockSection title="Work Order Details">
         <apex:outputfield label="Account" value="{!Work_Order__c.Account__c}" id="a"/>

         <apex:inputField label="Status" value="{!Work_Order__c.Status__c}" required="true"/>
          <apex:inputField label="Service Date" value="{!Work_Order__c.Service_Date__c}" required="true"/>


        </apex:pageblockSection>



        <apex:pageblockSection title="Summary">

        <apex:chart height="350" width="450" data="{!pieData}">
            <apex:pieSeries dataField="data" labelField="name"/>
            <apex:legend position="bottom"/>
        </apex:chart>


        </apex:pageblockSection>
                 <apex:pageblocksection title="Products" >

               <apex:outputPanel title="Family">
               <apex:outputLabel value="Family:"> &nbsp;&nbsp;
               <apex:actionRegion >              
                <apex:selectList value="{!selectedproductfamily}" size="1" label="Family"  rendered="true" >
                    <apex:actionSupport action="{!query}" reRender="pb1" id="fam" event="onchange"/> 

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

                </apex:selectList>
                   </apex:actionRegion> 
                   </apex:outputLabel>
                   </apex:outputPanel>  
            </apex:pageblocksection>
     <!--     </apex:pageBlock> -->

       <!--   <apex:pageBlock id="pb1" mode="edit">   -->
         <apex:pageblocktable value="{!queryResult}" var="acc" id="pb1">
          <apex:column >
          <apex:facet name="header">Name</apex:facet>
          <apex:outputfield value="{!acc.Name}" />
          </apex:column>
          <apex:column headervalue="Family">
          <apex:outputfield value="{!acc.Family}" />
          </apex:column>
          <apex:column headervalue="Measurement Type">
          <apex:outputfield value="{!acc.Measurement_Type__c}" />
           </apex:column>
          <apex:column headervalue="Treatment Price">
           <apex:outputfield value="{!acc.Treatment_Unit_Price__c}" />
          </apex:column>
          <apex:column headervalue="Cleaning Unit Price">
           <apex:outputfield value="{!acc.Cleaning_Unit_Price__c}" />
           </apex:column>

          <apex:column headerValue="Service">
          <apex:repeat value="{!acc.work_order_items__R}" var="b">
          <apex:inputfield value="{!b.Service__c}"/>
          </apex:repeat>
          </apex:column>


          <apex:column headerValue="Quantity">
          <apex:repeat value="{!acc.work_order_items__R}" var="b">
          <apex:inputfield value="{!b.Quantity__c}"/>
          </apex:repeat>
          </apex:column>

           <apex:column headerValue="Length">
           <apex:repeat value="{!acc.work_order_items__R}" var="b">
          <apex:inputfield value="{!b.Length__c}"/>
          </apex:repeat>
          </apex:column>

           <apex:column headerValue="Width">
           <apex:repeat value="{!acc.work_order_items__R}" var="b">
          <apex:inputfield value="{!b.Width__c}"/>
          </apex:repeat>
          </apex:column> 

          </apex:pageblocktable>

        </apex:pageblock> 
    </apex:form>
</apex:page>

Regards
Hi All,

I am using the below code to display chart on vf page . But it is not displaying anything. Can anyone have a look- 
 
public with sharing class wrapper_test_controller {
public list<wrapperclass> wrapperelement_for_account{get;set;}
public list<wrapperclass> wrapperelement_for_contact{get;set;}
public string selectedproductfamily {get;set;}
public list<Work_Order_Item__c> queryResult{get;set;}

public List<SelectOption> getproductfamily(){
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('None', 'None'));
        options.add(new SelectOption('Bedding', 'Bedding'));
        options.add(new SelectOption('Flooring', 'Flooring'));
        options.add(new SelectOption('Seating', 'Seating'));
        options.add(new SelectOption('Wall Treatments', 'Wall Treatments'));
        options.add(new SelectOption('Other', 'Other'));
        
        return options;
}

    public PageReference query() {
    system.debug('@@@'+selectedproductfamily);

        String qryString = 'select Product__r.Measurement_Type__c,Product__r.Treatment_Unit_Price__c,Product__r.Cleaning_Unit_Price__c,Product__c,Product__r.Name,Product__r.Family,id,name,Service__c,Quantity__c,Length__c,Width__c from Work_Order_Item__c WHERE ' +

            '(Product__r.Family like \'%' + selectedproductfamily + '%\')';

        queryResult = Database.query(qryString);
        
        return null;

    }

//list<Product2> object1 = [select id,name,Family,Measurement_Type__c,Treatment_Unit_Price__c,Cleaning_Unit_Price__c from Product2 limit 10];
//list<Work_Order_Item__c> object2 = [select Product__r.Measurement_Type__c,Product__r.Treatment_Unit_Price__c,Product__r.Cleaning_Unit_Price__c,Product__c,Product__r.Name,Product__r.Family,id,name,Service__c,Quantity__c,Length__c,Width__c from Work_Order_Item__c limit 10];

public wrapper_test_controller (ApexPages.StandardController controller) {

 }

//public list<wrapperclass> getaccountwrapperret(){
//wrapperelement_for_account = new list<wrapperclass>();
//for(Product2 obj1: object1){
//wrapperelement_for_account.add(new wrapperclass(obj1));
//}
//return wrapperelement_for_account;
//}
public list<wrapperclass> getPieData() {
 List<wrapperclass> data = new List<wrapperclass>();

List<Work_Order_Item__c> memb = new List<Work_Order_Item__c>();  
        

 AggregateResult[] groupedResults  = [SELECT count(Id) c, Product__r.Family f
        FROM Work_Order_Item__c
        WHERE Product__r.Family != null
        GROUP BY Product__r.Family];
 
 system.debug('@@@@'+ groupedResults);
 system.debug('@@@@'+ groupedResults.size());
 for (AggregateResult ar : groupedResults)  {            
                   
                     data.add(new wrapperclass(
                         String.ValueOf(ar.get('f')),
                         Double.ValueOf(ar.get('c'))
                         ));
                        
             }      
             return data; 
 
}
public class wrapperclass{
public String name { get; set; }  
 public Decimal data { get; set; }  
public Product2 object_account_1{get;set;}
public Work_Order_Item__c object_contact_2{get;set;}

public wrapperclass(Product2 obj1){
this.object_account_1 = (obj1);
}
public wrapperclass(Work_Order_Item__c obj2){
this.object_contact_2 = (obj2);}
public wrapperclass(String name, Decimal data) {
 this.name = name;  
 this.data = data;  
}
}
}

VF PAge - 
 
<apex:page standardController="Work_Order__c" extensions="wrapper_test_controller">
    <apex:form >
        <apex:pageblock id="pb">
        
        <apex:pageblockSection title="Work Order Details">
         <apex:inputField label="Account" value="{!Work_Order__c.Account__c}" required="true"/>
         
         <apex:inputField label="Status" value="{!Work_Order__c.Status__c}" required="true"/>
          <apex:inputField label="Service Date" value="{!Work_Order__c.Service_Date__c}" required="true"/>
        
        
        </apex:pageblockSection>
        <apex:pageblockSection title="Summary">
        
        <apex:chart height="350" width="450" data="{!pieData.size}">
            <apex:pieSeries dataField="data" labelField="Name"/>
            <apex:legend position="bottom"/>
        </apex:chart>
        
        
        </apex:pageblockSection>
                 <apex:pageblocksection title="Products" >
               
               <apex:outputPanel title="Family">
               <apex:outputLabel value="Family:"> &nbsp;&nbsp;
               <apex:actionRegion >              
                <apex:selectList value="{!selectedproductfamily}" size="1" label="Family"  rendered="true" >
                    <apex:actionSupport action="{!query}" reRender="pb1" id="fam" event="onchange"/> 
                    
                    <apex:selectOptions value="{!productfamily}" />
                    
                </apex:selectList>
                   </apex:actionRegion> 
                   </apex:outputLabel>
                   </apex:outputPanel>  
            </apex:pageblocksection>
          </apex:pageBlock>
          
          <apex:pageBlock id="pb1" mode="edit">  
         <apex:pageblocktable value="{!queryResult}" var="acc">
          <apex:column value="{!acc.Product__r.Name}" />
          <apex:column value="{!acc.Product__r.Family}" />
          <apex:column value="{!acc.Product__r.Measurement_Type__c}" />
          <apex:column value="{!acc.Product__r.Treatment_Unit_Price__c}" />
          <apex:column value="{!acc.Product__r.Cleaning_Unit_Price__c}" />
          <apex:column headerValue="Service">
          <apex:inputfield value="{!acc.Service__c}"/>
          </apex:column>
          
          <apex:column headerValue="Quantity">
          <apex:inputfield value="{!acc.Quantity__c}"/>
          </apex:column>
          
           <apex:column headerValue="Length">
          <apex:inputfield value="{!acc.Length__c}"/>
          </apex:column>
          
           <apex:column headerValue="Width">
          <apex:inputfield value="{!acc.Width__c}"/>
          </apex:column>

          </apex:pageblocktable>
        </apex:pageblock>
    </apex:form>
</apex:page>

I checked in inspect element i got a javascript error - 

SfdcCore.js:384 Visualforce Chart: Error loading configuration for chart 'jid0jid1pbjid3jid4': Unable to infer data model from result: result is not an Arrayb.resolve.b.provide.log @ SfdcCore.js:384 https://login.salesforce.com/17181/logo180.png Failed to load resource: the server responded with a status of 404 (Not Found)

Not sure wht tht means.

While debug i am getting in log the below - 
 
USER_DEBUG|[57]|DEBUG|@@@@(AggregateResult:{c=26, f=Bedding})



Regards

0down votefavoriteI have a wrapper class variable as -
map<String,wrapperOrder> workOrderNameToSumMap = new map<String,wrapperOrder>();
When i am trying to assign to a string variable i am getting error
String maxKey = workOrderNameToSumMap.isEmpty()?null:new List<String>(workOrderNameToSumMap.keyset())[0]; for(String s1:workOrderNameToSumMap.keySet()) { maxKey = workOrderNameToSumMap.get(s1)>workOrderNameToSumMap.get(maxKey)?s1:maxKey; }

Error -
Inequality operator not allowed for this type: wrapperOrder

 
There are two objects account and contact. There is a picklist field on contact called service and a field on account called prefered service.
there can be n no of contacts for an account.
My requirement is
i have 5 contact records C1,C2,C3,C4,C5 under an account A1.
C1- is having service as plumber
C2- is having service as carpenter
C3- is having service as plumber
C4- is having service as gardenner
C5- is having service as plumber
once inserted/updated it should check which of the picklist values is having more no of occurance and  prefered service field of account should get updated with mostly used values as "Plumber"
How can i achieve that?
Regards
Hi All,

I have a requirement where i need to have a batch class which calculates no of contact roles on opportunity and display on a custom field on opportunity. Can anyone help me with this how to write it.

Regards
Hi All,

I have a requirement where i need to have a batch class which calculates no of contact roles on opportunity. Can anyone help me with this how to write it.

Regards
Hi All,

Can anyone let me know how to calculate no of contact roles on opportunity.

Regards
Hi All,


0down votefavorite

I have a vf page where I have a lookup field as Account.MyThunder__Account__c
and a inputtext field Account.MyThunder__Business_Hours__c.

I want if i select user as 'X' then text field should appear else remain hidden.

How can we achieve this scenario.
 
<apex:page standardController="Account" >
<apex:form >
<apex:pageBlock id="xxxpb1">

<apex:pageBlockSection>

<apex:actionRegion >               

  <apex:inputField id="xxxif1" value="{!Account.MyThunder__Account__c}" required="true" >

     <apex:actionSupport event="onchange" rerender="xxxpb1" />
  </apex:inputField>

</apex:actionRegion>

</apex:pageBlockSection>


<apex:pageBlockSection id="xxxpbs1" rendered="true">

 <apex:inputField id="xxxif2" value="{!Account.MyThunder__Business_Hours__c }" rendered="{!IF(Account.MyThunder__Account__r.Name =='United Oil & Gas Corp.',true,false)}"/>

</apex:pageBlockSection>


</apex:PageBlock>
</apex:form>    
</apex:page>

 
Hi All,

I have a requirement where I am extracting date , month n year from a text field. I need to insert this value into a date data type field. How to do this..

Regards
I have a class which assigns Name field by appending two other fields -

Ex -

Name = Name + '-' + Market__c;

I have a trigger which appends the name with autonumber -

Name = Name + '-' + Market__c + '-' + autonumber;

Below is the problem which i am facing -

On insert it creates the name like -

Name = X-A-1

When i insert another record it creates the name like -

Name = X-A-1-1
Name = X-B-2

But i want the on insert it should continue the autonumber, Not start it again from 1st record.
 
trigger childrfptest on ChildRFP__c (after insert) {
    integer auto=1;
    set<id> uatid = new set<id>();

    for(ChildRFP__c r:trigger.new){
        uatid.add(r.id); 
    }

    List<ChildRFP__c> cp = new List<ChildRFP__c>();
    List<ChildRFP__c> cp1 = new List<ChildRFP__c>();
    cp = [select Parent_RFP__c from ChildRFP__c where id =:uatid];

    for(ChildRFP__c cd: cp)
    {    
       cp1=  [select Id,Name from ChildRFP__c where Parent_RFP__c =:cd.Parent_RFP__c];

    }
    auto=1;
    for( ChildRFP__c cd1: cp1)
    {

        cd1.Name= cd1.Name + '-'+ auto;
        update cd1;

        auto++;
    }

}

Regards
 
Can anyone provide some idea or approach on how to create a multiselect picklist like below pic.User-added image

Regards
Hi All,

I was going through the site http://www.datatables.net/.There is an example which is shown in the site.
User-added image

When this particular example is seen in TAB or mobile the columns are sorted out like below - 
User-added image

Can anyone help me out how this can be achieved in visualforce page. 
 
Hi All,

I am in need of some code snipet where i will be displaying a calender in vf page (Not Full page calender) and need to display all the events by week, month and the same will be displayed in mobile.

Regards
 
Hi,

Is there any tool to check salesforce apex unused variables and methods..Kindly suggest.

Regards
Hi All,

Can anyone tell me how to insert dynamically created dates fields from vf page. 

Below is a sample from jsfiddle.

http://jsfiddle.net/swm53ran/331/

Regards
I am trying the below code to add field history as a related list of opportunity in vf page, but its not working .
 
<apex:relatedList list="OpportunityFieldHistory"/>


Can anyone tell me what is the correct way to write it.
Regards
 
Hi All,

Can anyone let me know how to calculate no of contact roles on opportunity.

Regards
Hi All,

I have an custom autonumber field in an custom object. Below is my trigger. But on record insert the trigger is not firing and field is not getting updated.

The requirement is - 

Every time the record is inserted , it should check the last digit and then the sequence should continue. Please help.
 
trigger Childrfpautonumber on ChildRFP__c (before insert) {
    
    List<ChildRFP__c> lstNum  = [SELECT Id,AutoNumber__c FROM ChildRFP__c Order BY Createddate DESC LIMIT 1];
    Integer intCounter = 0;
    for(ChildRFP__c obj: lstNum)
    {
        intCounter ++;
        obj.AutoNumber__c = intCounter;
    }

}

 
Hi All,

I am trying to copy the values from one previous row to current one. Below is the javascript i am trying, but i am not getting - 

Below is vf page  & Javascript- 
 
<apex:page standardController="RFP__c" extensions="RFPController" sidebar="false" standardStylesheets="false">
    
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <c:FixSfdcFocusHack />
    <c:JQuery />
    <c:Chosen />

    <apex:form >
        <apex:pageBlock id="pb">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!Cancel}" value="Cancel"/>
            </apex:pageBlockButtons>
            
           <apex:pageBlockSection title="Business RFP Details" columns="1" collapsible="false">
                
                <apex:inputField value="{!accounts.Name}" />
                <apex:inputField value="{!accounts.Date_Requested__c}" />
                <apex:inputField value="{!accounts.Industry__c}" />
                <apex:inputField value="{!accounts.Primary_Contact__c}" />
                <apex:inputField value="{!accounts.Client_Advertiser__c}" />
                <apex:inputField value="{!accounts.Agency__c}" />
                <apex:inputField value="{!accounts.Renewal__c}" />
                <apex:inputField value="{!accounts.Rep_Name__c}" />
                <apex:inputField value="{!accounts.Account_Clearance__c}" />
                <apex:inputField value="{!accounts.Client_Budget__c}" />
                <apex:inputField value="{!accounts.Campaign_Marketing_Objectives__c}" />
                <apex:inputField value="{!accounts.Campaign_Name_Identifer__c}" />  
                
            </apex:pageBlockSection>  
            
            <apex:pageMessages />
            <apex:outputText rendered="{!isRerender}">
                
            </apex:outputText>      
            <apex:variable var="rowNumber" value="{!0}"/>
            
            
            <apex:pageBlockSection title="Child RFP Details" collapsible="false" id="section">
                
                
                <apex:pageBlockTable id="thetable"  var="acc" value="{!attendeeList1}" onRowMouseOver="removeHighlight(this)">
                    
                    <!--  <apex:column headerValue="Action" >-->
                       <!-- <apex:commandLink value="Copy" reRender="pb" onclick="testMe(rowNumber)" oncomplete="renderChosen()" /> -->
                        <apex:column headerValue="Copy" >
                    <apex:inputCheckbox value="{!acc.radiochk}" label="Copy">
                           <apex:actionSupport event="onchange" action="{!addRow}" rerender="pb"  oncomplete="renderChosen()" status="actStatusId"/>
  
                            </apex:inputCheckbox>
                    </apex:column>
                    
                    <apex:column headerValue="Custom Package">
                        <apex:param name="rowIndex" value="{!rowNumber}"/>
                        
                        <apex:selectList multiselect="true" value="{!acc.discountSchedule}"  styleClass="fullWidth chzn-select" size="1" style="width:400px;" id="cp" >
                            <apex:actionSupport event="onchange" action="{!acc.updateMarketOptions}" rerender="geographies,mar" oncomplete="renderChosen()" />
                            <apex:selectOptions value="{!acc.Items}"/>
                        </apex:selectList> 
                        <apex:variable var="rowNumber" value="{!rowNumber+1}"/> 
                    </apex:column>
                    
                    
                    <apex:column headerValue="Market" id="market">
                        <apex:outputPanel id="geographies" layout="block" >
                            
                            <apex:selectList id="selectedmarkets" multiselect="false" value="{!acc.discountSchedule1}"  styleClass="fullWidth chzn-select " size="1" style="width:150px" >
                                <apex:actionSupport event="onchange" action="{!acc.updateRestOptions}" rerender="state,First,second,third,forth,fifth" oncomplete="renderChosen()" />
                                <apex:selectOptions value="{!acc.marketOptions}"/>
                            </apex:selectList> 
                            
                        </apex:outputPanel>
                    </apex:column>  
                    
                    
                    <apex:column id="state" headerValue="State" >
                        
                        <apex:inputField value="{!acc.cp.State__c}" styleClass="twitterStyleTextbox" id="st"/>
                    </apex:column>
                    <apex:column id="First" headerValue="First Issue" >
                        <apex:inputfield value="{!acc.cp.First_Issue__c}" styleClass="twitterStyleTextbox"/>
                    </apex:column>
                    <apex:column id="second" headerValue="Last Issue" >
                        <apex:inputField value="{!acc.cp.Last_Issue__c}" styleClass="twitterStyleTextbox"/>
                    </apex:column>
                    <apex:column id="third" headerValue="Circulation" >
                        <apex:inputField value="{!acc.cp.Circulation__c}" styleClass="twitterStyleTextbox"/>
                    </apex:column>
                    <apex:column id="forth" headerValue="Space Unit">
                        <apex:inputField value="{!acc.cp.Space_Unit__c }" styleClass="chzn-select"/>
                    </apex:column>
                    <apex:column id="fifth" headerValue="Per Unit Open Rate">
                        <apex:inputField value="{!acc.cp.Per_Unit_Open_Rate__c}" styleClass="twitterStyleTextbox"/>
                    </apex:column>
                    <apex:column id="six" headerValue="Space Discount">
                        <apex:inputtext value="{!acc.spacediscount}" styleClass="twitterStyleTextbox" id="sp" >
                            <apex:actionSupport event="onchange" action="{!acc.calculategrossrate}" rerender="seven"/>
                        </apex:inputtext>
                    </apex:column>
                    <apex:column id="seven" headerValue="Per Unit Gross Rate">
                        <apex:inputtext value="{!acc.perunitgross}" styleClass="twitterStyleTextbox" id="pg" html-readonly="true">
                            <apex:actionSupport event="onclick" action="{!acc.calculatetotalnet}" rerender="eight"/>
                        </apex:inputtext>
                    </apex:column>
                    <apex:column id="eight" headerValue="Total Net">
                        <apex:inputtext value="{!acc.totalnet}" styleClass="twitterStyleTextbox" id="tn" html-readonly="true">
                        <apex:actionSupport event="onclick" action="{!totalnetbottom}" rerender="tob"  oncomplete="renderChosen()"/>
                        </apex:inputtext>
                    </apex:column>
                    <apex:column width="25px" headerValue="Remove">
                        <apex:inputCheckbox value="{!acc.checked}">
                            <apex:actionSupport event="onchange" action="{!deleteLanguage}" rerender="pb"  oncomplete="renderChosen()"/>
                        </apex:inputCheckbox>
                    </apex:column>  
                </apex:pageBlockTable>
            </apex:pageBlockSection>
                        <apex:outputLabel id="tob" value="Total Net :" style="font-weight: bold;float:right; position: absolute;right:109px;">&nbsp;&nbsp;
            <apex:inputtext value="{!totalnetbottom}" styleClass="twitterStyleTextbox" id="tnb" html-readonly="true">
            
            </apex:inputtext>
            </apex:outputLabel>
            <apex:commandButton action="{!addRow}" value="Add Row" reRender="pb" oncomplete="renderChosen()"> 
                <apex:param name="rowIndex" value="{!rowNumber}"/>
            </apex:commandButton>
            <apex:outputText rendered="{!isRerender}">
      
        <script type="text/javascript">
            var table = document.getElementById('{!$Component.pb.thetable}');
                alert(table);
            var lastRow = table.rows[table.rows.length - 1];
            var prevRow = table.rows[table.rows.length - 2];
            var arrSourceInputs = prevRow.getElementsByTagName("input");
            var arrDestInputs = lastRow.getElementsByTagName("input");
            for(var i in arrSourceInputs){
                if(arrSourceInputs[i].type == "text"){
                    arrDestInputs[i].value = arrSourceInputs[i].value; 
                }
            }
        </script> 
        
      </apex:outputText>        
        </apex:pageblock>
    </apex:form>
</apex:page>
I kept an alert in the javascirpt .. On fired i am getting null..

Regards
Hi,

I have a vf page which on action:support firing needs to display all the fields. But i am able to not able to get all the fields displayed in pageblocksection fields. Can anyone help me out in this .

VF Page - 
 
<apex:pageBlockTable id="thetable"  var="acc" value="{!attendeeList1}" onRowMouseOver="removeHighlight(this)">
        
             <apex:column headerValue="Action" >
            <apex:commandLink value="Copy" reRender="pb" onclick="testMe(event)"/>
          </apex:column>
          
          <apex:column headerValue="Custom Package">
                 <apex:param name="rowIndex" value="{!rowNumber}"/>
                         <apex:selectList multiselect="true" value="{!acc.discountSchedule}"  styleClass="fullWidth chzn-select" size="1" style="width:400px;" >
                          <apex:actionSupport event="onchange" action="{!acc.updateMarketOptions}" rerender="geographies"  oncomplete="renderChosen()"/>
                        <apex:selectOptions value="{!Dept}"/>
                      </apex:selectList> 
                <apex:variable var="rowNumber" value="{!rowNumber+1}"/> 
          </apex:column>
           

          <apex:column headerValue="Market" id="market">
            <apex:outputPanel id="geographies" layout="block" >
          <apex:selectList id="selectedmarkets" multiselect="false" value="{!acc.discountSchedule1}"  styleClass="fullWidth chzn-select" size="1" style="width:150px" >
                
              <apex:selectOptions value="{!acc.marketOptions}"/>
             </apex:selectList> 
            </apex:outputPanel>
          </apex:column>
          
          <apex:column headerValue="State" >
            <apex:inputField value="{!acc.cp.State__c}" styleClass="twitterStyleTextbox"/>
          </apex:column>
          <apex:column headerValue="First Issue" >
            <apex:inputField value="{!acc.cp.First_Issue__c}" styleClass="twitterStyleTextbox"/>
          </apex:column>
          <apex:column headerValue="Last Issue" >
            <apex:inputField value="{!acc.cp.Last_Issue__c}" styleClass="twitterStyleTextbox"/>
          </apex:column>
          <apex:column headerValue="Circulation" >
            <apex:inputField value="{!acc.cp.Circulation__c}" styleClass="twitterStyleTextbox"/>
          </apex:column>
            <apex:column headerValue="Space Unit">
            <apex:inputField value="{!acc.cp.Space_Unit__c }" styleClass="chzn-select"/>
          </apex:column>
          <apex:column headerValue="Space Discount">
          <apex:inputField value="{!acc.cp.Space_Discount__c}" styleClass="twitterStyleTextbox"/>
          </apex:column>
           <apex:column headerValue="Per Unit Open Rate">
          <apex:inputField value="{!acc.cp.Per_Unit_Open_Rate__c}" styleClass="twitterStyleTextbox"/>
          </apex:column>
  <!--         <apex:column headerValue="Action">
          <apex:commandLink value="Delete" reRender="pb"  oncomplete="renderChosen()" action="{!deleteLanguage}" />
          </apex:column> -->
          <apex:column width="25px" headerValue="Remove">
           <apex:inputCheckbox value="{!acc.checked}">
           <apex:actionSupport event="onchange" action="{!deleteLanguage}" rerender="pb"  oncomplete="renderChosen()"/>
           </apex:inputCheckbox>
            </apex:column>
        </apex:pageBlockTable>

Apex Class - 
 
public with sharing class RFPController{

        public RFP__c accounts{get;set;}
        public Custom_Package__c del;
        public List < Custom_Package__c > addattendeeList {get;set;}
        public List < Custom_Package__c > delattendeeList {get;set;}
        public List < Custom_Package__c > attendeeList {get;set;}
        public Integer totalCount {get;set;}
        public Integer rowIndex {get;set;}
        public Integer deleterowIndex {get;set;}
        public List < Custom_Package__c > delAttendees {get;set;}
        public Boolean isRerender{get;set;}
         public Integer numberOfRowToRemove { get; set; }
         public String selectedRowIndex{get;set;} 
         public Integer c{get; set;} 
         private List<SelectOption> options;
         public List<SelectOption> AllName{get;set;}
         public List<SelectOption> AllDept{get;set;}
        public String discountScheduleID2 { get; set; }
        public  string mark {get; set;}
        public Integer rowNum{get;set;}
             

        private List<Custom_Package__c>  acc {get;set;}
        
        public RFPController(ApexPages.StandardController controller) {

                isRerender = false;
                accounts =  (RFP__c )controller.getRecord();
              /*  String S = 'Select id, Name, Market__c, State__c, First_Issue__c,Last_Issue__c,Circulation__c,Space_Unit__c,Per_Unit_Open_Rate__c,Space_Discount__c from Custom_Package__c ';
                //totalCount = attendeeList.size();
                attendeeList  = Database.Query(S);
                attendeeList = new List < Custom_Package__c >();
          
                delattendeeList = new List < Custom_Package__c > ();
                delattendees = new List < Custom_Package__c > (); */
               
                accounts.Rep_Name__c= Userinfo.getuserId();
                c=0;
               //AllName = getMarket();
                //Alldept = getDept();
                attendeeList1 = new List<CustomPackageWrapper>();
                for(integer i=0;i<5;i++){
                
                CustomPackageWrapper cw1 = new CustomPackageWrapper(new Custom_Package__c());
                cw1.rowIndex=0;
                //cw1.discountSchedule.add('a1I540000008VtY');
                attendeeList1.add(cw1);

                }
   
        }
 
        public void addRow() {
                isRerender = true;
               
               CustomPackageWrapper cw = new CustomPackageWrapper(new Custom_Package__c());
               cw.rowIndex= c+1;
               
               c=c+1;
              
               
               
               attendeeList1.add(cw);


        }
        
       public void deleteLanguage() 
       {

        List<Custom_Package__c> langsToDelete = new List<Custom_Package__c>();
            for ( Integer i = 0; i < attendeeList1.size(); i++ ) {
        if ( attendeeList1[i].checked ) {
            langsToDelete.add(attendeeList1.remove(i--).cp);
        }
    }
    langsToDelete.clear();

       }
        

    public List<ID> discountScheduleID {
        get {
            if (discountScheduleID == null) {
                discountScheduleID = new List<ID>();
            }
            return discountScheduleID ;
        }
        set;
    }
    
      public List<SelectOption> getDept()
    {
        List<SelectOption> options = new List<SelectOption>();
        //options.add(new SelectOption('Select','--Select--'));
        
        for(Custom_Package__c Proj  :[select Id, Name from Custom_Package__c ] )
             {
                    system.debug('3333333'); 
                    options.add(new SelectOption(Proj.ID,Proj.Name));
                    
             }
        return options;
        
    }
 
   
   public Integer selectedRowIdx {get; set;}
   Public List<CustomPackageWrapper> cplist = new List<CustomPackageWrapper>();
   public CustomPackageWrapper cp2 = new CustomPackageWrapper (new Custom_Package__c() ); 
   Public List<CustomPackageWrapper> WrapperList{get;set;}
        
    
  public List<SelectOption> getMarket(){
            //system.debug('^^^^^^^^ Entered' +cp.discountSchedule );
                List<SelectOption> options = new List<SelectOption>();
                //cp.discountSchedule = new List<ID>();
               integer d=0;
             for(Custom_Package__c Proj1  :[select Id,Market__c from Custom_Package__c where ID IN:attendeeList1[d].discountSchedule and ID Not in :attendeeList1[c].discountSchedule ] )
                    {                    
                       // system.debug('3333333' + cp.discountSchedule ); 
                       // CustomPackageWrapper cp = new CustomPackageWrapper (new Custom_Package__c());
                       //  cp.discountSchedule.add(Proj1.Market__c );
                       //  cplist.add(cp );
                        options.add(new SelectOption(Proj1.ID,Proj1.Market__c ));
                        
                    }
                  
            //system.debug('^^^^^^^^ Entered' + options.size());        
            return options;
            

        }
    
    public string selectedMarketIds {get; set;}  
    
        public void FindAllName()
    {
        AllName= new List<SelectOption>();
        AllDept= new List<SelectOption>();
        system.debug('!!!!!!! Entered');
        
        
        AllName = getMarket();
        Alldept = getDept();
        system.debug('&&&&&&& Entered' + AllName );

    }
    
    public List<Custom_Package__c> editList   {get;set;}
    
    public void initList(){
          
        editList = [SELECT Name,
                           Market__c,
                           State__c,
                           First_Issue__c,
                           Last_Issue__c,
                           Circulation__c,
                           Space_Unit__c ,
                           Space_Discount__c,
                           Per_Unit_Open_Rate__c
                           FROM Custom_Package__c
                           ];
                           
        for(Custom_package__c c : editList){
            attendeeList1.add(new CustomPackageWrapper(c));
             
        }       
          
        }

    
    public List<CustomPackageWrapper> attendeeList1 {
        get {if (attendeeList1 == null)
             attendeeList1 = new List<CustomPackageWrapper>();
             return attendeeList1;
       }
        set;
        }



        public class CustomPackageWrapper {
        public Custom_Package__c cp {get; set;}
        public Integer rowIndex {get;set;}
        public List<ID> discountSchedule {
        get {
            if (discountSchedule == null) {
                discountSchedule = new List<ID>();
            }
            return discountSchedule ;
        }
        set;
        }
        
        public List<SelectOption> marketOptions {
        get {
            if (marketOptions == null) {
                marketOptions = new List<SelectOption>();
            }
            return marketOptions ;
        }
        set;
        }
        
        public List<String> stateOptions {
        get {
            if (stateOptions == null) {
                stateOptions = new List<String>();
            }
            return stateOptions ;
        }
        set;
        }
        
    public boolean checked {get; set;}
    
    public void updateMarketOptions() {
        marketOptions.clear();
        
        for (Custom_Package__c cp1 : [select Id, Market__c, state__c from Custom_Package__c where Id in :discountSchedule order by Market__c ]) {
            marketOptions.add(new SelectOption(cp1.Id, cp1.Market__c));
        }
        }

        public string discountSchedule1 {get;set;} 
        

        public string state{get; set;}

        public CustomPackageWrapper(Custom_Package__c cp) {
        this.cp = cp;
        this.checked = false;
        }

        }

}

 
Hi All,

I have a vf page where i am adding rows dynamically. Once i add rows i need to copy the values from previous rows to current row. Is there a way to do it via javasscript. How to get the rowindex . 
 
<apex:pageBlockSection title="Child RFP Details" collapsible="false" id="section">
      
        <apex:pageBlockTable id="thetable"  var="acc" value="{!attendeeList1}" onRowMouseOver="removeHighlight(this)">
        
             <apex:column headerValue="Action" >
            <apex:commandLink value="Copy" reRender="pb" onclick="testMe(event)"/>
          </apex:column>
          
          <apex:column headerValue="Custom Package">
                 <apex:param name="rowIndex" value="{!rowNumber}"/>
                         <apex:selectList multiselect="true" value="{!acc.discountSchedule}"  styleClass="fullWidth chzn-select" size="1" style="width:400px;" >
                          <apex:actionSupport event="onchange" action="{!acc.updateMarketOptions}" rerender="geographies"  oncomplete="renderChosen()"/>
                        <apex:selectOptions value="{!Dept}"/>
                      </apex:selectList> 
                <apex:variable var="rowNumber" value="{!rowNumber+1}"/> 
          </apex:column>
           

          <apex:column headerValue="Market" id="market">
            <apex:outputPanel id="geographies" layout="block" >
          <apex:selectList id="selectedmarkets" multiselect="false" value="{!acc.discountSchedule1}"  styleClass="fullWidth chzn-select" size="1" style="width:150px" >
                
              <apex:selectOptions value="{!acc.marketOptions}"/>
             </apex:selectList> 
            </apex:outputPanel>
          </apex:column>
          
          <apex:column headerValue="State" >
            <apex:inputField value="{!acc.cp.State__c}" styleClass="twitterStyleTextbox"/>
          </apex:column>
          <apex:column headerValue="First Issue" >
            <apex:inputField value="{!acc.cp.First_Issue__c}" styleClass="twitterStyleTextbox"/>
          </apex:column>
          <apex:column headerValue="Last Issue" >
            <apex:inputField value="{!acc.cp.Last_Issue__c}" styleClass="twitterStyleTextbox"/>
          </apex:column>
          <apex:column headerValue="Circulation" >
            <apex:inputField value="{!acc.cp.Circulation__c}" styleClass="twitterStyleTextbox"/>
          </apex:column>
            <apex:column headerValue="Space Unit">
            <apex:inputField value="{!acc.cp.Space_Unit__c }" styleClass="chzn-select"/>
          </apex:column>
          <apex:column headerValue="Space Discount">
          <apex:inputField value="{!acc.cp.Space_Discount__c}" styleClass="twitterStyleTextbox"/>
          </apex:column>
           <apex:column headerValue="Per Unit Open Rate">
          <apex:inputField value="{!acc.cp.Per_Unit_Open_Rate__c}" styleClass="twitterStyleTextbox"/>
          </apex:column>
  <!--         <apex:column headerValue="Action">
          <apex:commandLink value="Delete" reRender="pb"  oncomplete="renderChosen()" action="{!deleteLanguage}" />
          </apex:column> -->
          <apex:column width="25px" headerValue="Remove">
           <apex:inputCheckbox value="{!acc.checked}">
           <apex:actionSupport event="onchange" action="{!deleteLanguage}" rerender="pb"  oncomplete="renderChosen()"/>
           </apex:inputCheckbox>
            </apex:column>
        </apex:pageBlockTable>

      </apex:pageBlockSection>
      <apex:commandButton action="{!addRow}" value="Add Row" reRender="pb" oncomplete="renderChosen()"> 
      <apex:param name="rowIndex" value="{!rowNumber}"/>
      
       </apex:commandButton>

</apex:pageblock>

Regards
Hi All,

I have a vf page where i am dynamically adding rows. I am using wrapper class to add empty rows evrytime. After selecting custom package values from selectlist , action:support is fired which in turn calling getMarket() method. This is currently is a single picklist and it is not displaying any values. At backned there is data. Please help where things has gone wrong. Is vf page binding incorreclty done..

Alex Class - 

public with sharing class RFPController{

    public RFP__c accounts;
        public Custom_Package__c del;
        public List < Custom_Package__c > addattendeeList {get;set;}
        public List < Custom_Package__c > delattendeeList {get;set;}
        public List < Custom_Package__c > attendeeList {get;set;}
        public Integer totalCount {get;set;}
        
        public Integer rowIndex {get;set;}
        public Integer deleterowIndex {get;set;}
        public List < Custom_Package__c > delAttendees {get;set;}
        public Boolean isRerender{get;set;}
        //public String S {get;set;}
         public Integer numberOfRowToRemove { get; set; }
         public String selectedRowIndex{get;set;} 
        //public Integer count = 1;
         public Integer c{get; set;} 
         //public Integer counter{get;set;}
         private List<SelectOption> options;
         public List<SelectOption> AllName{get;set;}
         public List<SelectOption> AllDept{get;set;}
        // public String discountScheduleID { get; set; }
        public  string mark {get; set;}
        
        Public List<CustomPackageWrapper> cplist = new List<CustomPackageWrapper>();
        public CustomPackageWrapper cp = new CustomPackageWrapper (new Custom_Package__c() ); 
        
        private List<Custom_Package__c>  acc {get;set;}
        
        public RFPController(ApexPages.StandardController controller) {

                isRerender = false;
                accounts =  (RFP__c )controller.getRecord();
                String S = 'Select id, Name, Market__c, State__c, First_Issue__c,Last_Issue__c,Circulation__c,Space_Unit__c,Per_Unit_Open_Rate__c,Space_Discount__c from Custom_Package__c ';
                //totalCount = attendeeList.size();
                attendeeList  = Database.Query(S);
                attendeeList = new List < Custom_Package__c >();
          
                delattendeeList = new List < Custom_Package__c > ();
                delattendees = new List < Custom_Package__c > ();
               
                accounts.Rep_Name__c= Userinfo.getuserId();
                c=0;
               // AllName = getMarket();
                Alldept = getDept();
                attendeeList1 = new List<CustomPackageWrapper>();
        }
 
        public void addRow() {
                isRerender = true;
               
               CustomPackageWrapper cw = new CustomPackageWrapper(new Custom_Package__c());
               
               attendeeList1.add(cw);


        }

        

    public List<ID> discountScheduleID {
        get {
            if (discountScheduleID == null) {
                discountScheduleID = new List<ID>();
            }
            return discountScheduleID ;
        }
        set;
    }
    
      public List<SelectOption> getDept()
    {
        List<SelectOption> options = new List<SelectOption>();
        //options.add(new SelectOption('Select','--Select--'));
        
        for(Custom_Package__c Proj  :[select Id, Name from Custom_Package__c ] )
             {
                    system.debug('3333333'); 
                    options.add(new SelectOption(Proj.ID,Proj.Name));
                    
             }
        return options;
        
    }
 
   
   public Integer selectedRowIdx {get; set;}

    
    public List<SelectOption> getMarket(){
        system.debug('^^^^^^^^ Entered' +cp.discountSchedule );
            List<SelectOption> options = new List<SelectOption>();
            //cp.discountSchedule = new List<ID>();
            
         for(Custom_Package__c Proj1  :[select Id,Market__c from Custom_Package__c where ID IN:cp.discountSchedule] )
                {                    
                    system.debug('3333333' + cp.discountSchedule ); 
                   // CustomPackageWrapper cp = new CustomPackageWrapper (new Custom_Package__c());
                   //  cp.discountSchedule.add(Proj1.Market__c );
                   //  cplist.add(cp );
                    options.add(new SelectOption(Proj1.ID,Proj1.Market__c ));
                    
                }
              
        system.debug('^^^^^^^^ Entered' + options.size());        
        return options;
        

    }
    
    public string selectedMarketIds {get; set;}  
    
        public void FindAllName()
    {
        AllName= new List<SelectOption>();
        AllDept= new List<SelectOption>();
        system.debug('!!!!!!! Entered');
        AllName = getMarket();
        Alldept = getDept();
        system.debug('&&&&&&& Entered' + AllName );

    }
    
    public List<CustomPackageWrapper> attendeeList1 {
        get {if (attendeeList1 == null)
             attendeeList1 = new List<CustomPackageWrapper>();
             return attendeeList1;
       }
        set;
        }



        public class CustomPackageWrapper {
        public Custom_Package__c cp {get; set;}
        //public List<ID> discountSchedule {get; set;}
        //public String discountSchedule1 {get; set;}
        public Integer rowIndex {get;set;}
        
        public List<ID> discountSchedule {
        get {
            if (discountSchedule == null) {
                discountSchedule = new List<ID>();
            }
            return discountSchedule ;
        }
        set;
        }
        
        public List<String> discountSchedule1 {
        get {
            if (discountSchedule1 == null) {
                discountSchedule1 = new List<String> ();
            }
            return discountSchedule1 ;
        }
        set;
        }
        
        public CustomPackageWrapper(Custom_Package__c cp) {
        
        
        this.cp = cp;
        
        
        }
        
       
        }

  
}



VF Page - 

<apex:page standardController="RFP__c" extensions="RFPController" sidebar="false">

<meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <c:FixSfdcFocusHack />
    <c:JQuery />
    <c:Chosen />
    <style type="text/css">
        .fullWidth { width: 100%; }
        .flightDateRangeText { font-size: 90%;  }
        
        .bPageBlock .requiredForSubmit .requiredBlock {
        background-color: #FFD700;
        bottom: 1px;
        left: -4px;
        position: absolute;
        top: 1px;
        width: 3px;
        }
        
        .bPageBlock .requiredForSubmitInput {
        height: 100%;
        position: relative;
        }
        
    </style>
    <script type="text/javascript">
    /* <![CDATA[ */
    
    /* 
         *  Render Chosen on select elements with the chzn-select class specified.
         */
         
    function renderChosen() {
   
            $j('.chzn-select').chosen();
            
    } 
    
    function focusChosen() {
        $j('.search-field').find("input").focus();       
    }       
    
    /*
         *  Render required marker on elements where class == "required".
         */
    function renderRequired() {
        $j('.required').wrap('<div class="requiredInput" />').before('<div class="requiredBlock" />');
    }
    
    /*
         *  Render required marker on elements with the specified ID.
         */        
    function renderRequiredComponentId(componentId) {
        $j(jq(componentId) + ' .required').wrap('<div class="requiredInput" />').before('<div class="requiredBlock" />');
    }
    
    var rfpRequiredIds = ["dueDate", "clientsEstablishedPartners", "campaignMarketingObjectives", "campaignGoals",
                          "scopeOfCampaign", "mediaRequested", "otherMediaRequested", "campaignTotalNet", 
                          "primaryTargetAudience", "geographies", "servingPreference", "clientServedSpecifics", "adSizes",
                          "creativeType", "richMediaType", "percentageFlash", "percentageRichMedia", "flightDateRanges"];
    
    var optRequiredFieldIds = ["planCompletionDate", "clientsEstablishedPartners",
                               "campaignMarketingObjectives", "campaignGoals", "scopeOfCampaign", "mediaRequested", "campaignComments",
                               "primaryTargetAudience", "geographies", "customGeoDetail", "servingPreference", "clientServedSpecifics",
                               "adSizes", "creativeType", "richMediaType", "additionalCreativeNotes"];
    
    //SSirikonda - 07/25/2013 - Removing the field Plan_completion_Date__c as yellow marked field when
    //RFP type drop-down = SEM   
    /*var semRequiredFieldIds = ["planCompletionDate", "url", 
           "campaignMarketingObjectives", "campaignComments", "geographies", "customGeoDetail"];*/
    
    var semRequiredFieldIds = ["url", 
                               "campaignMarketingObjectives", "campaignComments", "geographies", "customGeoDetail"];
    
    function modifyRequired() {
        $j('.requiredForSubmitInput').removeClass('requiredForSubmitInput');
        var type = $j('[id$="type"]').val();
        if (type == 'RFP') {
            $j.each(rfpRequiredIds, function(index, value) {
                var selector = '[id$="' + value + '"]';
                $j(selector).addClass('requiredForSubmitInput');
            });
        } else if (type == 'OPT') {
            $j.each(optRequiredFieldIds, function(index, value) {
                var selector = '[id$="' + value + '"]';
                $j(selector).addClass('requiredForSubmitInput');
            });
        } else if (type == 'SEM') {
            $j.each(semRequiredFieldIds, function(index, value) {
                var selector = '[id$="' + value + '"]';
                $j(selector).addClass('requiredForSubmitInput');
            });
        }
    }
    
    function changePrimaryContact() {
        var value = $j('[id$="primaryContact"]').val();
        var selector = '[id$="agencyContact"]';
        $j(selector).removeClass('requiredInput');
        var selector = '[id$="agency"]';
        $j(selector).removeClass('requiredInput');
        if (value == 'Agency') {
            var selector = '[id$="agency"]';
            $j(selector).addClass('requiredInput');
            var selector = '[id$="agencyContact"]';
            $j(selector).addClass('requiredInput');
        }
    }
    
    $j(document).ready(function() {
        renderChosen();
        renderRequired();
        clearErrors();
        changePrimaryContact();
        modifyRequired();
    });
    
    /* ]]> */        
    </script>
    <style>
   .twitterStyleTextbox {
    border: 1px solid #c4c4c4;
    width: 180px;
    height: 18px;
    font-size: 13px;
    padding: 4px 4px 4px 4px;
    border-radius: 4px;
    -moz-border-radius: 4px;
    -webkit-border-radius: 4px;
    box-shadow: 0px 0px 8px #d9d9d9;
    -moz-box-shadow: 0px 0px 8px #d9d9d9;
    -webkit-box-shadow: 0px 0px 8px #d9d9d9;
}

.twitterStyleTextbox:focus {
    outline: none;
    border: 1px solid #7bc1f7;
    box-shadow: 0px 0px 8px #7bc1f7;
    -moz-box-shadow: 0px 0px 8px #7bc1f7;
    -webkit-box-shadow: 0px 0px 8px #7bc1f7;
}
 </style>
    

<apex:form id="myForm">
<apex:pageBlock id="pb">
        <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!Cancel}" value="Cancel"/>
         </apex:pageBlockButtons>

<apex:pageMessages />
      <apex:outputText rendered="{!isRerender}">

      </apex:outputText>      
      <apex:variable var="rowNumber" value="{!0}"/>
      
     
      <apex:pageBlockSection title="Child RFP Details" collapsible="false" id="section">
      
        <apex:pageBlockTable id="thetable"  var="acc" value="{!attendeeList1}" onRowMouseOver="removeHighlight(this)">
        
             <apex:column headerValue="Action" >
            <apex:commandLink value="Copy" reRender="pb" onclick="testMe(event)"/>
          </apex:column>
          
          <apex:column headerValue="Custom Package">
                 <apex:param name="rowIndex" value="{!rowNumber}"/>
                         <apex:selectList multiselect="true" value="{!acc.discountSchedule}"  styleClass="fullWidth chzn-select" size="1" style="width:400px;" >
                          <apex:actionSupport event="onchange" action="{!FindAllName}" rerender="geographies"  oncomplete="renderChosen()"/>
                        <apex:selectOptions value="{!Dept}"/>
                      </apex:selectList> 
                <apex:variable var="rowNumber" value="{!rowNumber+1}"/> 
          </apex:column>
           

          <apex:column headerValue="Market" id="market">
            <apex:outputPanel id="geographies" layout="block" >
          <apex:selectList id="selectedmarkets" multiselect="false" value="{!acc.discountSchedule1}"  styleClass="fullWidth chzn-select" size="1" style="width:150px" >
                
              <apex:selectOptions value="{!Market}"/>
             </apex:selectList> 
            </apex:outputPanel>
          </apex:column>
          
          <apex:column headerValue="State" >
            <apex:inputField value="{!acc.cp.State__c}" styleClass="twitterStyleTextbox"/>
          </apex:column>
          <apex:column headerValue="First Issue" >
            <apex:inputField value="{!acc.cp.First_Issue__c}" styleClass="twitterStyleTextbox"/>
          </apex:column>
          <apex:column headerValue="Last Issue" >
            <apex:inputField value="{!acc.cp.Last_Issue__c}" styleClass="twitterStyleTextbox"/>
          </apex:column>
          <apex:column headerValue="Circulation" >
            <apex:inputField value="{!acc.cp.Circulation__c}" styleClass="twitterStyleTextbox"/>
          </apex:column>
            <apex:column headerValue="Space Unit">
            <apex:inputField value="{!acc.cp.Space_Unit__c }" styleClass="chzn-select"/>
          </apex:column>
          <apex:column headerValue="Space Discount">
          <apex:inputField value="{!acc.cp.Space_Discount__c}" styleClass="twitterStyleTextbox"/>
          </apex:column>
           <apex:column headerValue="Per Unit Open Rate">
          <apex:inputField value="{!acc.cp.Per_Unit_Open_Rate__c}" styleClass="twitterStyleTextbox"/>
          </apex:column>

        </apex:pageBlockTable>

      </apex:pageBlockSection>
      <apex:commandButton action="{!addRow}" value="Add Row" reRender="pb" oncomplete="renderChosen()"> 
      <apex:param name="rowIndex" value="{!rowNumber}"/>
      
       </apex:commandButton>
            
</apex:pageblock>
</apex:form>
</apex:page>

​Regards
I have a vf page where i am dynamically adding rows. I am using wrapper class to add empty rows evrytime.

On Vf page there is an action support which calls getMarket() method. The prob here is i am unable to figure out how to use discountSchedule (present in wrapper class) variable in getMarket() SOQL so that my action support will work.

Now after clicking addrow button i am getting the following error - 

 
System.NullPointerException: Attempt to de-reference a null object 
External entry point




Below is the vf page and apex class -

Apex Classs - 

    public with sharing class RFPController{

        public RFP__c accounts;
            public Custom_Package__c del;
            public List < Custom_Package__c > addattendeeList {get;set;}
            public List < Custom_Package__c > delattendeeList {get;set;}
            public List < Custom_Package__c > attendeeList {get;set;}
            public Integer totalCount {get;set;}
            
            public Integer rowIndex {get;set;}
            public Integer deleterowIndex {get;set;}
            public List < Custom_Package__c > delAttendees {get;set;}
            public Boolean isRerender{get;set;}
            //public String S {get;set;}
             public Integer numberOfRowToRemove { get; set; }
             public String selectedRowIndex{get;set;} 
            //public Integer count = 1;
             public Integer c{get; set;} 
             //public Integer counter{get;set;}
             private List<SelectOption> options;
             public List<SelectOption> AllName{get;set;}
             public List<SelectOption> AllDept{get;set;}
            // public String discountScheduleID { get; set; }
            public  string mark {get; set;}
            
            Public List<CustomPackageWrapper> cplist = new List<CustomPackageWrapper>();
            public CustomPackageWrapper cp = new CustomPackageWrapper (new Custom_Package__c() ); 
            
            private List<Custom_Package__c>  acc {get;set;}
            
            public RFPController(ApexPages.StandardController controller) {

                    isRerender = false;
                    accounts =  (RFP__c )controller.getRecord();
                    String S = 'Select id, Name, Market__c, State__c, First_Issue__c,Last_Issue__c,Circulation__c,Space_Unit__c,Per_Unit_Open_Rate__c,Space_Discount__c from Custom_Package__c ';
                    //totalCount = attendeeList.size();
                    attendeeList  = Database.Query(S);
                    attendeeList = new List < Custom_Package__c >();
                    for(integer i=0;i<1;i++){ 
                    attendeeList .add(new Custom_Package__c ());
                    }
                    delattendeeList = new List < Custom_Package__c > ();
                    delattendees = new List < Custom_Package__c > ();
                   
                    accounts.Rep_Name__c= Userinfo.getuserId();
                    c=0;
                    AllName = getMarket();
                    Alldept = getDept();
                    
            }
     
            public void addRow() {
                    isRerender = true;
                    
                   CustomPackageWrapper cw = new CustomPackageWrapper(new Custom_Package__c());
                   attendeeList1.add(cw);


            }

            

        public List<ID> discountScheduleID {
            get {
                if (discountScheduleID == null) {
                    discountScheduleID = new List<ID>();
                }
                return discountScheduleID ;
            }
            set;
        }
        
          public List<SelectOption> getDept()
        {
            List<SelectOption> options = new List<SelectOption>();
            //options.add(new SelectOption('Select','--Select--'));
            
            for(Custom_Package__c Proj  :[select Id, Name from Custom_Package__c ] )
                 {
                        system.debug('3333333'); 
                        options.add(new SelectOption(Proj.ID,Proj.Name));
                        
                 }
            return options;
            
        }
     
       
       public Integer selectedRowIdx {get; set;}

        
        public List<SelectOption> getMarket(){
            system.debug('^^^^^^^^ Entered' + discountScheduleID );
                List<SelectOption> options = new List<SelectOption>();

             for(Custom_Package__c Proj1  :[select Id,Market__c from Custom_Package__c where ID=:cp.discountSchedule ] )
                    {
                        system.debug('3333333' + discountScheduleID ); 
                        CustomPackageWrapper cp = new CustomPackageWrapper (new Custom_Package__c());
                         cp.discountSchedule.add(Proj1.Market__c );
                         cplist.add(cp );
                        options.add(new SelectOption(Proj1.ID,Proj1.Market__c ));
                        
                    }
                  
            system.debug('^^^^^^^^ Entered' + options.size());        
            return options;
            

        }
        
        public string selectedMarketIds {get; set;}  
        
            public void FindAllName()
        {
            AllName= new List<SelectOption>();
            AllDept= new List<SelectOption>();
            system.debug('!!!!!!! Entered');
            AllName = getMarket();
            Alldept = getDept();
            system.debug('&&&&&&& Entered' + AllName );

        }
        
        public List<CustomPackageWrapper> attendeeList1 {
            get {if (attendeeList1 == null)
                 attendeeList1 = new List<CustomPackageWrapper>();
                 return attendeeList1;
           }
            set;
            }



            public class CustomPackageWrapper {
            public Custom_Package__c cp {get; set;}
            public List<String> discountSchedule {get; set;}
            public Integer rowIndex {get;set;}
            
            public CustomPackageWrapper(Custom_Package__c cp) {this.cp = cp;}
            
           
            }

      
    }

VF Page - 

   <apex:page standardController="RFP__c" extensions="RFPController" sidebar="false">

<meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <c:FixSfdcFocusHack />
    <c:JQuery />
    <c:Chosen />
    <style type="text/css">
        .fullWidth { width: 100%; }
        .flightDateRangeText { font-size: 90%;  }

        .bPageBlock .requiredForSubmit .requiredBlock {
        background-color: #FFD700;
        bottom: 1px;
        left: -4px;
        position: absolute;
        top: 1px;
        width: 3px;
        }

        .bPageBlock .requiredForSubmitInput {
        height: 100%;
        position: relative;
        }

    </style>
    <script type="text/javascript">
    /* <![CDATA[ */

    /* 
         *  Render Chosen on select elements with the chzn-select class specified.
         */

    function renderChosen() {

            $j('.chzn-select').chosen();

    } 

    function focusChosen() {
        $j('.search-field').find("input").focus();       
    }       

    /*
         *  Render required marker on elements where class == "required".
         */
    function renderRequired() {
        $j('.required').wrap('<div class="requiredInput" />').before('<div class="requiredBlock" />');
    }

    /*
         *  Render required marker on elements with the specified ID.
         */        
    function renderRequiredComponentId(componentId) {
        $j(jq(componentId) + ' .required').wrap('<div class="requiredInput" />').before('<div class="requiredBlock" />');
    }

    var rfpRequiredIds = ["dueDate", "clientsEstablishedPartners", "campaignMarketingObjectives", "campaignGoals",
                          "scopeOfCampaign", "mediaRequested", "otherMediaRequested", "campaignTotalNet", 
                          "primaryTargetAudience", "geographies", "servingPreference", "clientServedSpecifics", "adSizes",
                          "creativeType", "richMediaType", "percentageFlash", "percentageRichMedia", "flightDateRanges"];

    var optRequiredFieldIds = ["planCompletionDate", "clientsEstablishedPartners",
                               "campaignMarketingObjectives", "campaignGoals", "scopeOfCampaign", "mediaRequested", "campaignComments",
                               "primaryTargetAudience", "geographies", "customGeoDetail", "servingPreference", "clientServedSpecifics",
                               "adSizes", "creativeType", "richMediaType", "additionalCreativeNotes"];

    //SSirikonda - 07/25/2013 - Removing the field Plan_completion_Date__c as yellow marked field when
    //RFP type drop-down = SEM   
    /*var semRequiredFieldIds = ["planCompletionDate", "url", 
           "campaignMarketingObjectives", "campaignComments", "geographies", "customGeoDetail"];*/

    var semRequiredFieldIds = ["url", 
                               "campaignMarketingObjectives", "campaignComments", "geographies", "customGeoDetail"];

    function modifyRequired() {
        $j('.requiredForSubmitInput').removeClass('requiredForSubmitInput');
        var type = $j('[id$="type"]').val();
        if (type == 'RFP') {
            $j.each(rfpRequiredIds, function(index, value) {
                var selector = '[id$="' + value + '"]';
                $j(selector).addClass('requiredForSubmitInput');
            });
        } else if (type == 'OPT') {
            $j.each(optRequiredFieldIds, function(index, value) {
                var selector = '[id$="' + value + '"]';
                $j(selector).addClass('requiredForSubmitInput');
            });
        } else if (type == 'SEM') {
            $j.each(semRequiredFieldIds, function(index, value) {
                var selector = '[id$="' + value + '"]';
                $j(selector).addClass('requiredForSubmitInput');
            });
        }
    }

    function changePrimaryContact() {
        var value = $j('[id$="primaryContact"]').val();
        var selector = '[id$="agencyContact"]';
        $j(selector).removeClass('requiredInput');
        var selector = '[id$="agency"]';
        $j(selector).removeClass('requiredInput');
        if (value == 'Agency') {
            var selector = '[id$="agency"]';
            $j(selector).addClass('requiredInput');
            var selector = '[id$="agencyContact"]';
            $j(selector).addClass('requiredInput');
        }
    }

    $j(document).ready(function() {
        renderChosen();
        renderRequired();
        clearErrors();
        changePrimaryContact();
        modifyRequired();
    });

    /* ]]> */        
    </script>
    <style>
   .twitterStyleTextbox {
    border: 1px solid #c4c4c4;
    width: 180px;
    height: 18px;
    font-size: 13px;
    padding: 4px 4px 4px 4px;
    border-radius: 4px;
    -moz-border-radius: 4px;
    -webkit-border-radius: 4px;
    box-shadow: 0px 0px 8px #d9d9d9;
    -moz-box-shadow: 0px 0px 8px #d9d9d9;
    -webkit-box-shadow: 0px 0px 8px #d9d9d9;
}

.twitterStyleTextbox:focus {
    outline: none;
    border: 1px solid #7bc1f7;
    box-shadow: 0px 0px 8px #7bc1f7;
    -moz-box-shadow: 0px 0px 8px #7bc1f7;
    -webkit-box-shadow: 0px 0px 8px #7bc1f7;
}
 </style>


<apex:form id="myForm">
<apex:pageBlock id="pb">
        <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!Cancel}" value="Cancel"/>
         </apex:pageBlockButtons>

<apex:pageMessages />
      <apex:outputText rendered="{!isRerender}">

      </apex:outputText>      
      <apex:variable var="rowNumber" value="{!0}"/>


      <apex:pageBlockSection title="Child RFP Details" collapsible="false" id="section">

        <apex:pageBlockTable id="thetable"  var="acc" value="{!attendeeList1}" onRowMouseOver="removeHighlight(this)">

             <apex:column headerValue="Action" >
            <apex:commandLink value="Copy" reRender="pb" onclick="testMe(event)"/>
          </apex:column>

          <apex:column headerValue="Custom Package">
                 <apex:param name="rowIndex" value="{!rowNumber}"/>
                         <apex:selectList multiselect="true" value="{!acc.discountSchedule}"  styleClass="fullWidth chzn-select" size="1" style="width:400px;" >
                          <apex:actionSupport event="onchange" action="{!FindAllName}" rerender="geographies"  oncomplete="renderChosen()"/>
                        <apex:selectOptions value="{!Dept}"/>
                      </apex:selectList> 
                <apex:variable var="rowNumber" value="{!rowNumber+1}"/> 
          </apex:column>


          <apex:column headerValue="Market" id="market">
            <apex:outputPanel id="geographies" layout="block" >
          <apex:selectList id="selectedmarkets" multiselect="false" value="{!selectedMarketIds }"  styleClass="fullWidth chzn-select" size="1" style="width:150px" >

              <apex:selectOptions value="{!Market}"/>
             </apex:selectList> 
            </apex:outputPanel>
          </apex:column>

          <apex:column headerValue="State" >
            <apex:inputField value="{!acc.cp.State__c}" styleClass="twitterStyleTextbox"/>
          </apex:column>
          <apex:column headerValue="First Issue" >
            <apex:inputField value="{!acc.cp.First_Issue__c}" styleClass="twitterStyleTextbox"/>
          </apex:column>
          <apex:column headerValue="Last Issue" >
            <apex:inputField value="{!acc.cp.Last_Issue__c}" styleClass="twitterStyleTextbox"/>
          </apex:column>
          <apex:column headerValue="Circulation" >
            <apex:inputField value="{!acc.cp.Circulation__c}" styleClass="twitterStyleTextbox"/>
          </apex:column>
            <apex:column headerValue="Space Unit">
            <apex:inputField value="{!acc.cp.Space_Unit__c }" styleClass="chzn-select"/>
          </apex:column>
          <apex:column headerValue="Space Discount">
          <apex:inputField value="{!acc.cp.Space_Discount__c}" styleClass="twitterStyleTextbox"/>
          </apex:column>
           <apex:column headerValue="Per Unit Open Rate">
          <apex:inputField value="{!acc.cp.Per_Unit_Open_Rate__c}" styleClass="twitterStyleTextbox"/>
          </apex:column>

        </apex:pageBlockTable>

      </apex:pageBlockSection>
      <apex:commandButton action="{!addRow}" value="Add Row" reRender="pb" oncomplete="renderChosen()"> 
      <apex:param name="rowIndex" value="{!rowNumber}"/>

       </apex:commandButton>

</apex:pageblock>
</apex:form>
</apex:page>                

Regards
 
 
Hi All,

i am facing one issue where i need to add empty rows dynamically in vf page on button click. But it is not happening. Currently when i am clicking addrow button it is copying values from previous rows and displaying. And if i add some new values in 2nd row and then click addrow, all the rows are getting filled with all the values selected.

Below are the screenshot for clarification -

1. Filled up the first filled from multiselect and clicked addrow button -

User-added image

2. In the 2nd row i selected a new value from multiselect and clicked addrow. After clicking all the 3 rows got filled up with all the data which i dont want. I want everytime i select a new empty row should get generated.

User-added image

User-added image

Please help . Below is the apex class - Let me know if vf page code is required.

    public with sharing class RFPController{

        public RFP__c accounts;
            public Custom_Package__c del;
            public List < Custom_Package__c > addattendeeList {get;set;}
            public List < Custom_Package__c > delattendeeList {get;set;}
            public List < Custom_Package__c > attendeeList {get;set;}
            public Integer totalCount {get;set;}
            
            public Integer rowIndex {get;set;}
            public Integer deleterowIndex {get;set;}
            public List < Custom_Package__c > delAttendees {get;set;}
            public Boolean isRerender{get;set;}
            //public String S {get;set;}
             public Integer numberOfRowToRemove { get; set; }
             public String selectedRowIndex{get;set;} 
            //public Integer count = 1;
             public Integer c{get; set;} 
             //public Integer counter{get;set;}
             private List<SelectOption> options;
             public List<SelectOption> AllName{get;set;}
             public List<SelectOption> AllDept{get;set;}
            // public String discountScheduleID { get; set; }
            public  string mark {get; set;}
            
            
            
            private List<Custom_Package__c>  acc {get;set;}
            
            public RFPController(ApexPages.StandardController controller) {

                    isRerender = false;
                    accounts =  (RFP__c )controller.getRecord();
                    String S = 'Select id, Name, Market__c, State__c, First_Issue__c,Last_Issue__c,Circulation__c,Space_Unit__c,Per_Unit_Open_Rate__c,Space_Discount__c from Custom_Package__c ';
                    //totalCount = attendeeList.size();
                    attendeeList  = Database.Query(S);
                    attendeeList = new List < Custom_Package__c >();
                    for(integer i=0;i<1;i++){ 
                    attendeeList .add(new Custom_Package__c ());
                    }
                    delattendeeList = new List < Custom_Package__c > ();
                    delattendees = new List < Custom_Package__c > ();
                   
                    accounts.Rep_Name__c= Userinfo.getuserId();
                    c=0;
                    AllName = getMarket();
                    Alldept = getDept();
                    
            }
     
            public void addRow() {
                    isRerender = true;
                    
                   //addattendeeList = new List < Custom_Package__c > ();
                   // attendeeList.add(new Custom_Package__c ());
                    //c=c+1;
                  
                    // c=c+1;
                     //discountScheduleID.clear();
                    //attendeeList[c].name=discountScheduleID[c];
                    
                  Custom_Package__c c = new Custom_Package__c ();
                  attendeeList.add(c);
                    
                    
            }

            

        public List<ID> discountScheduleID {
            get {
                if (discountScheduleID == null) {
                    discountScheduleID = new List<ID>();
                }
                return discountScheduleID ;
            }
            set;
        }
        
          public List<SelectOption> getDept()
        {
            List<SelectOption> options = new List<SelectOption>();
            //options.add(new SelectOption('Select','--Select--'));
            
            for(Custom_Package__c Proj  :[select Id, Name from Custom_Package__c ] )
                 {
                        system.debug('3333333'); 
                        options.add(new SelectOption(Proj.ID,Proj.Name));
                        
                 }
            return options;
            
        }

        
        public List<SelectOption> getMarket(){
            system.debug('^^^^^^^^ Entered' + discountScheduleID );
                List<SelectOption> options = new List<SelectOption>();
            
             for(Custom_Package__c Proj1  :[select Id,Market__c from Custom_Package__c where ID=:discountScheduleID  ] )
                    {
                        system.debug('3333333' + discountScheduleID ); 
                        options.add(new SelectOption(Proj1.ID,Proj1.Market__c ));
                        
                    }
                  
            system.debug('^^^^^^^^ Entered' + options.size());        
            return options;
            

        }
        
        public string selectedMarketIds {get; set;}  
        
            public void FindAllName()
        {
            AllName= new List<SelectOption>();
            AllDept= new List<SelectOption>();
            system.debug('!!!!!!! Entered');
            AllName = getMarket();
            Alldept = getDept();
            system.debug('&&&&&&& Entered' + AllName );

        }
        
      
      
    }

Regards
Hi All,

I have a vf page where I have inputfields. I need to align those fields in a column wise. Can anyone help me align the fields - 

Current VF Page - 

User-added image

I need to display the above page as below - 

User-added image

VF page - 

<apex:page standardController="Contact" extensions="ContactController">
    <apex:form >
    <apex:pageMessages />
    <apex:pageBlock >
        <apex:pageBlockSection title="Pick an account!" id="addressData" columns="7">
            <apex:inputField value="{!c.LastName}" />
            <apex:inputField value="{!c.AccountId}">
                <apex:actionSupport event="onchange" action="{!fetchRelatedAccountData}" rerender="addressData" status="requestStatus"/>
            </apex:inputField>
            <apex:actionStatus id="requestStatus" startText="(requesting...)"  stopText=" (done)"/>

            <apex:inputField value="{!c.MailingStreet}" />

            <apex:inputField value="{!c.MailingCity}" />
            <apex:inputField value="{!c.MailingPostalCode}" />
            <apex:outputField value="{!c.MailingCountry}" />
       </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:form>
</apex:page>

Regards
Hi All,

I am using action support to display data in textbox. But I am getting the below errros while executing - 

Visualforce Error
Help for this Page
System.QueryException: List has no rows for assignment to SObject
Error is in expression '{!ContactPopulated}' in page autopu: Class.ManageListController.ContactPopulated: line 59, column 1
Class.ManageListController.ContactPopulated: line 59, column 1


Below is my apex class and vf page - 

Apex Class - 


public class ManageListController 
{
 public List<AccountWrapper> wrappers {get; set;}
 public static Integer toDelIdent {get; set;}
 public static Integer addCount {get; set;}
 private Integer nextIdent=0;
 public Custom_Package__c wimsContact {get;set;}
 public String S {get;set;}
  
 public ManageListController()
 {
  wrappers=new List<AccountWrapper>();
  for (Integer idx=0; idx<5; idx++)
  {
   wrappers.add(new AccountWrapper(nextIdent++));
  }
 }
  
 public void delWrapper()
 {
  Integer toDelPos=-1;
  for (Integer idx=0; idx<wrappers.size(); idx++)
  {
   if (wrappers[idx].ident==toDelIdent)
   {
    toDelPos=idx;
   }
  }
   
  if (-1!=toDelPos)
  {
   wrappers.remove(toDelPos);
  }
 }
  
 public void addRows()
 {
  for (Integer idx=0; idx<addCount; idx++)
  {
   wrappers.add(new AccountWrapper(nextIdent++));
  }
 }
  
 public PageReference save()
 {
  List<Custom_Package__c> accs=new List<Custom_Package__c>();
  for (AccountWrapper wrap : wrappers)
  {
   accs.add(wrap.acc);
  }
   
  insert accs;
   
 return new PageReference('/' + Schema.getGlobalDescribe().get('Custom_Package__c').getDescribe().getKeyPrefix() + '/o');
 }
 
 public void ContactPopulated(){
   
    wimsContact =[select Per_Unit_Open_Rate__c,Space_Discount__c,Space_Unit__c,Circulation__c,First_Issue__c,Last_Issue__c,State__c,id,name, Market__c from Custom_Package__c where Name =:S]; 
    system.debug('@@@@' + wimsContact );
}
  
 public class AccountWrapper
 {
  public Custom_Package__c acc {get; private set;}
  public Integer ident {get; private set;}
   
  public AccountWrapper(Integer inIdent)
  {
   ident=inIdent;
   acc=new Custom_Package__c();
  }
 }
}

VF Page - 

<apex:page tabstyle="Account" controller="ManageListController">
<apex:form >
   <apex:pageBlock title="Custom Package" id="thePageBlock">
      <apex:pageBlockTable value="{!wrappers}" var="wrapper" id="wtable">
         <apex:column headerValue="Ident">
            <apex:outputText value="{!wrapper.ident}"/>
         </apex:column>
         <apex:column headerValue="Name">
            <apex:inputText value="{!S}">
            
            <apex:actionSupport event="onchange" action="{!ContactPopulated}" rerender="thePageBlock" status="status"/>
            </apex:inputText>
            <apex:actionStatus startText="applying address..." id="status"/>
         </apex:column>
         <apex:column headerValue="Market">
            <apex:inputField value="{!wrapper.acc.Market__c}"/>
         </apex:column>
         <apex:column headerValue="State">
            <apex:inputField value="{!wrapper.acc.State__c}"/>
         </apex:column>
         <apex:column headerValue="Action">
            <apex:commandButton value="Delete" action="{!delWrapper}" rerender="wtable">
               <apex:param name="toDelIdent" value="{!wrapper.ident}" assignTo="{!toDelIdent}"/> 
            </apex:commandButton>
         </apex:column>
      </apex:pageBlockTable>
      <apex:commandButton value="Add Row" action="{!addRows}" rerender="wtable">
         <apex:param name="addCount" value="1" assignTo="{!addCount}"/> 
      </apex:commandButton>
      <apex:commandButton value="Add 5 Rows" action="{!addRows}" rerender="wtable">
         <apex:param name="addCount" value="5" assignTo="{!addCount}"/> 
      </apex:commandButton>
      <apex:commandButton value="Save" action="{!save}"/>
   </apex:pageBlock>
 </apex:form>
 
</apex:page>

Regards
Hi All,

I have a button and a textbox in vf page. I want when i click the button the focus should go to textbox. Below is my vf page - 

        <apex:commandbutton value="Search" action="{!FindAllName}" rerender="geographies" oncomplete="renderChosen()" style="width:120px;margin-left:30px;" status="actStatusId" id="cmdbutton" />    
                        </div>
                        
                        <apex:actionStatus id="actStatusId">
                            <apex:facet name="start" >
                                <apex:image url="/img/loading32.gif" width="15" height="15"  style="float:left;margin-left: 430px;;margin-top:-16px;"/>              
                            </apex:facet>
                        </apex:actionStatus>
                        
                        
                        <apex:pageBlockSectionItem id="geo">
                            <apex:outputLabel value="{!$ObjectType.RFP__c.Fields.Geography__c.Label}"  style="width:87%; float:right;height:12px;font-weight:bold;font-family:Arial;font-size:11px;color:#2F4F4F;"/>
                            <apex:outputPanel id="geographies" layout="block"  styleClass="requiredInput" style="width:82%; float:right;margin-top:-10px;">
                                <apex:outputPanel id="geos" layout="block"  styleClass="requiredBlock"/>
                                <apex:outputText value="Please Refine Your Search" rendered="{!IF(results >1000,'true','false')}" style="margin-left:-2px;width:100%; margin-top:-10px;font-weight:bold;font-family:Arial;font-size:11px;color:red;"/>
                                <apex:outputText value="No Results Found" rendered="{!IF(results ==0,'true','false')}" style="margin-left:-2px;width:100%; margin-top:-10px;font-weight:bold;font-family:Arial;font-size:11px;color:black;"/>
                                <apex:selectList value="{!selectedGeographyIds }" multiselect="true" id="selectedGeographies" styleClass="fullWidth chzn-select" >
                                    
                                    <apex:selectOptions value="{!AllName}" id="movieTextBox"></apex:selectOptions>
                                    
                                </apex:selectList>
                                
                                <apex:outputPanel layout="block" styleClass="errorMsg" >
                                    <apex:outputText value="{!errorMap['selectedGeographies']}" 
                                                     escape="false" rendered="{!errorMap['selectedGeographies'] != ''}" />
                                </apex:outputPanel>
                            </apex:outputPanel>
                        </apex:pageBlockSectionItem>
                    </apex:actionregion> 

Regards
When I rerender a selectlist id's and a field is required but not filled, then an error is displayed on page. I don't want these errors untill I click on save button. So, for this i added <apex:actionregion> tag which prevented this, but the formatting got disturbed. 

Below is thw code where rerender happens -

<apex:actionregion >
    <apex:pageBlockSectionItem >
   <apex:outputLabel value="{!$ObjectType.RFP__c.Fields.Country__c.Label}" />
    <apex:outputPanel id="countries" layout="block"  styleClass="requiredInput">
    <apex:outputPanel id="countr" layout="block"  styleClass="requiredBlock"/>

    <apex:selectList value="{!discountScheduleID}" size="1" styleClass="fullWidth chzn-select">
            <apex:actionSupport event="onchange" action="{!FindAllName}" rerender="geographies" oncomplete="renderChosen()" />
            <apex:selectOptions value="{!dept}" />
    </apex:selectList> 

    </apex:outputPanel>

    </apex:pageBlockSectionItem>
    <apex:pageBlockSectionItem >
    <apex:outputLabel value="{!$ObjectType.RFP__c.Fields.Geography__c.Label}" />
    <apex:outputPanel id="geographies" layout="block"  styleClass="requiredInput">
    <apex:outputPanel id="geos" layout="block"  styleClass="requiredBlock"/>

    <apex:selectList value="{!selectedGeographyIds }" multiselect="true" id="selectedGeographies" styleClass="fullWidth chzn-select" >
            <apex:selectOptions value="{!AllName}" id="movieTextBox"></apex:selectOptions>
        </apex:selectList>

        <apex:outputPanel layout="block" styleClass="errorMsg" >
                            <apex:outputText value="{!errorMap['selectedGeographies']}" 
                                escape="false" rendered="{!errorMap['selectedGeographies'] != ''}" />
    </apex:outputPanel>
    </apex:outputPanel>
    </apex:pageBlockSectionItem>
    </apex:actionregion>

It should be like below - 

User-added image

But it is looking like this - 

User-added image

Regards
Hi All,

I hv a vf page where i need to populate default value as ' United States' on [page load and also geography field should get all the regions related to United States.

Below is my VF page & controller method.

Controller -

public List<SelectOption> getDept()
        {
            List<SelectOption> options = new List<SelectOption>();
            options.add(new SelectOption('Select','--Select--'));
            Schema.DescribeFieldResult departfield =  Geography__c.Country__c.getDescribe();
            List<Schema.PicklistEntry> picklist = departfield.getPicklistValues();
            for( Schema.PicklistEntry f : picklist){      
            options.add(new SelectOption(f.getLabel(), f.getValue()));
     
            }    
            return options;
            
         }

VF Page - 

<apex:form id="form">
        <apex:pageMessages />
        <apex:selectList value="{!discountScheduleID}" size="1" styleClass="fullWidth chzn-select">
            <apex:actionSupport event="onchange" action="{!FindAllName}" rerender="geographies" oncomplete="renderChosen()"/>
            <apex:selectOptions value="{!dept}" />
        </apex:selectList>  

          <apex:outputLabel value="{!$ObjectType.RFP__c.Fields.Geography__c.Label}" />
              <apex:outputPanel id="geographies" layout="block"  styleClass="requiredInput">
           <apex:outputPanel id="geos" layout="block"  styleClass="requiredBlock"/>
         <apex:selectList value="{!selectedGeographyIds }" multiselect="true" id="selectedGeographies" styleClass="fullWidth chzn-select" >
            <apex:selectOptions value="{!AllName}" id="movieTextBox"></apex:selectOptions>
        </apex:selectList>
        <apex:outputPanel layout="block" styleClass="errorMsg" >
                            <apex:outputText value="{!errorMap['selectedGeographies']}" 
                                escape="false" rendered="{!errorMap['selectedGeographies'] != ''}" />
                        </apex:outputPanel>
                    </apex:outputPanel>

    </apex:form>

Regards