• xzuvel
  • NEWBIE
  • 25 Points
  • Member since 2010

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 8
    Replies

Hi im currently developing a VF page that contains serveral picklist dependants of each other. But in other to work you must click on the 1st for the second to populate himself.

 

Code :

 

 Sub-Type: <apex:selectList title="Sub-Type" id="selectlist7" value="{!select7}"  size="1">
                       <apex:actionSupport event="onclick" reRender="selectlist8"/>
                       <apex:selectOptions value="{!SubType}"/>    
                     </apex:selectList>
            
            Product Description: <apex:selectList title="Product Description" id="selectlist8" value="{!select8}"  size="1">
                           <apex:actionSupport event="onclick" reRender="output"  />
                               <apex:selectOptions value="{!Description}"/>    
                      </apex:selectList>

 

its okei when you 2 to 4 but when you have 6 to 12 it starts to get really annoing and problematic.

They start to not respond so well. is there anyway to improve this maybe another type of action support or is there a better way to do this?

 

Thx for al the help in advance.

  • September 14, 2010
  • Like
  • 0

Hi thanks for all the answers in advance.

 

My problem right now is the following :

 

I make the following SOQL to get some values of the product2 table. I need to DISTINCT them but currently SOQL doesnt have the functionallity. Im trying a work around and i wanted to know if it was posible.

 

 

Right now I have the following code:

 

 

 List<SelectOption> options = new List<SelectOption>();
         options.add(new SelectOption('N/A','N/A'));
         if (select2 == 'BP'){
           for(product2 tmp : [select minutes__c from product2 where sub_family_C = 'BP']{
                   for(Integer k = 0 ; k < tmp.size() ; k++){
                      if(tmp[k].minutes__c != tmp[k].minutes__c){
                          options.add(new SelectOption (tmp.minutes__C ,tmp.minutes__C));
                       }
               }
           }
         return options;

 

 

I cant seem to get it right. I just want to populate my product list and then traverse the list to find if the value is already there if it is then dont add it to the list.

 

Again thanks for all the help!.

  • September 07, 2010
  • Like
  • 0

hi im trying to get the string value out of a List<product2> ( list of products), So I can display it on a apex:outputtext.

 

 

Al the help is really appreciated.

 

 

My VF page Code :

 

 <apex:selectList title="Marca" id="selectlist2" value="{!select2}" size="1">
        <apex:actionSupport event="onclick" reRender="output"/>
        <apex:selectOptions value="{!items2}"/>    
        </apex:selectList>

 

<apex:outputText id="output"   style="font-style:italic" value="{0}" rendered="true" title="Producto">
        <apex:param value="{!items3}" />
</apex:outputText>

 

My controller Code:

 

    public List<SelectOption> getItems2()
    {
        List<SelectOption> options = new List<SelectOption>();
        if(select1 == 'Modem1'){
          List<Product2> proList = [select name from Product2 where ProductCode like '0001-%'];
          for(product2 a : proList)
           options.add(new SelectOption(a.Name,a.Name));
        }
        else if(select1 == 'Modem2'){
          List<Product2> proList = [select name from Product2 where ProductCode like '0000-%'];
          for(product2 a : proList)
          options.add(new SelectOption(a.Name,a.Name));
        }
        
        return options;
    }
    public List<Product2> getItems3()
    {
        List<Product2> proList = [select ProductCode from Product2 where name = :select2 limit 1];
        return prolist;
    }

 

I need to return a string value from my list :

 

       public String  getItems3()
    {
        List<Product2> proList = [select ProductCode from Product2 where name = :select2 limit 1];
        return prolist;
    }

  • August 19, 2010
  • Like
  • 0

Hi. Im trying to add a product using APEX code.  I've Develop some kind of a product "Selecter or Wizard".

 

Ive created a custom button in the opportunity page that sends the user to my custom page.

 

I need to find  a way to get the id of the opportunity in that button or any other way, so i can link the final product to the opportunity you were working before entering my product wizard.

 

Also, if i'm able match the Opportunityid with the OpportunitylineitemId and pricebookid and finally the product2id. All the information about the product should appear in my opportunity ?

 

 

I appreciate all the help.

 

This is the code :

 

 

Controller:

 

public with sharing class Product_Wizard_Controller {

    Opportunity opportunity;
    OpportunitylineItem lineitem;
    Product2 product;
    String test = 'Celulares';
    List<SelectOption> value= new List<SelectOption>();
    List<SelectOption> option = new List<SelectOption>();


    public List<SelectOption> getItems1()
    {
        List<SelectOption> option = new List<SelectOption>(option);  
        option.add(new SelectOption('Modem1','Celulares'));
        option.add(new SelectOption('Modem2','DSL'));
        option.add(new SelectOption('Modem3','ATM'));
        option.add(new SelectOption('Modem4','VOIP'));
        option.add(new SelectOption('Modem5','Modem5'));
        return option;
    }
    
    
    public List<SelectOption> getItems2()
    {
        List<SelectOption> options = new List<SelectOption>();
        if(select1 == 'Modem1'){
          List<Product2> proList = [select name from Product2 where ProductCode like '0001-%'];
          for(product2 a : proList)
           options.add(new SelectOption(a.Name,a.Name));
        }
        else if(select1 == 'Modem2'){
          List<Product2> proList = [select name from Product2 where ProductCode like '0000-%'];
          for(product2 a : proList)
          options.add(new SelectOption(a.Name,a.Name));
        }
        
        return options;
    }
    public List<SelectOption> getItems3()
    {
        List<SelectOption> options = new List<SelectOption>();
        List<Product2> proList = [select ProductCode from Product2 where name = :select2 limit 10];
        for(product2 a : proList)
        options.add(new SelectOption(a.ProductCode,a.ProductCode));
        return options;
    }
    
    public List<SelectOption> getModem()
    {
        List<SelectOption> option = new List<SelectOption>();  
        option.add(new SelectOption('Modem1','CISCO'));
        option.add(new SelectOption('Modem2','MX456'));
        option.add(new SelectOption('Modem3','DLINK'));
        option.add(new SelectOption('Modem4','MOTOROLA'));
        option.add(new SelectOption('Modem5','GHTYU678'));
        return option;
    }

     
   // This method cancels the wizard, and returns the user to the   
   // Opportunities tab  
    
    public PageReference cancel() {
            PageReference opportunityPage = new ApexPages.StandardController(opportunity).view();
            opportunityPage.setRedirect(true);
            return opportunityPage;
    }
    
    public void addProduct()
    {
            PageReference opportunityPage = new ApexPages.StandardController(opportunity).view();
            opportunityPage.setRedirect(true);   
    }
   
    Public string select1{get; set;}
    Public string select2{get; set;}
    Public string select3{get; set;}
    Public string select4{get; set;}

}

 

 

VF code:

 

<apex:page controller="Product_Wizard_Controller">

  <script>
   function confirmCancel() {
        var isCancel = confirm("Are you sure you wish to cancel?");
        if (isCancel) return true;
        return false;
    }  
  </script>

  <apex:sectionHeader title="Product Wizard" subtitle="Select a Product: " help="Contact Your Administrator"/>
    <!--Toolbar -->
    <apex:toolbar id="theToolbar" height="20"  style="background-color:#00CCFF;background-image:none;color:#EEECD1" width="100%" >
        <apex:outputText value="Navigation Toolbar" style="color:#000000"/>
         <apex:toolbarGroup itemSeparator="line" id="toobarGroupLinks" style="color:#FFFFF0">
            <apex:outputLink value="https://na7.salesforce.com/home/showAllTabs.jsp" style="color:#FFFFF0">
              salesforce +
            </apex:outputLink>
            <apex:outputLink value="https://na7.salesforce.com/006/o" style="color:#FFFFF0">
             Opportunitties
            </apex:outputLink>
            <apex:outputLink value="https://c.na7.visual.force.com/apex/bundle" style="color:#FFFFF0">
             Bundles
            </apex:outputLink>
            <apex:outputLink value="https://na7.salesforce.com/01t/oe" style="color:#FFFFF0">
             Products
            </apex:outputLink>

            
         </apex:toolbarGroup>
         <apex:toolbarGroup itemSeparator="line" location="right" id="toobarGroupForm">
            <apex:form id="theForm">
                <apex:inputText id="theInputText">Enter Text:</apex:inputText>
                <apex:commandLink value="search" id="theCommandLink"/>
            </apex:form>
         </apex:toolbarGroup>
    </apex:toolbar>

    <apex:form >
       <apex:pageBlock title="Products: " mode="edit">
       
       Tipo de Producto:  <apex:selectList id="picklist1" title="Tipo" id="selectlist1" value="{!select1}" size="1">
        <apex:actionSupport event="onclick" reRender="selectlist2" reRender="selectlist2"/>
        <apex:selectOptions value="{!items1}"/>    
        </apex:selectList>

       Marca:  <apex:selectList title="Marca" id="selectlist2" value="{!select2}" size="1">
        <apex:actionSupport event="onclick"  reRender="selectlist3"/>
        <apex:selectOptions value="{!items2}"/>    
        </apex:selectList>

       Numero de Producto:  <apex:selectList title="Numero de Producto"  id="selectlist3" value="{!select3}" size="1">
        <apex:selectOptions value="{!items3}"/>    
        </apex:selectList>
        
       Tipo de Modem <apex:selectList id="selectlist4" value="{!select4}" size="1">
         <apex:selectOptions value="{!Modem}"/>
        </apex:selectList>
        
        <apex:pageBlockButtons >
          <apex:commandButton action="{!addProduct}" value="Add"/>
          <apex:commandButton action="{!cancel}" value="Cancel"
                              onclick="return confirmCancel()" immediate="true"/>
        </apex:pageBlockButtons>        
       </apex:pageBlock>
     </apex:form>

</apex:page>

 

 

 

 

  • August 16, 2010
  • Like
  • 0

Hi, I need help retrieving the option the user selected of a pre-determine values of a picklist I created. So my other indepedent picklist retrieves the value depending on the user first selection.

 

Thanks for all the Help you can give.

 

Here's the Code:

 

Controller Code:

 

    Public string select1{get; set;}
    Public string select2{get; set;}

 


    public List<SelectOption> getItems()
    {
        List<SelectOption> option = new List<SelectOption>(option); 
        option.add(new SelectOption('Modem1','Celulares'));
        option.add(new SelectOption('Modem2','Dmax'));
        option.add(new SelectOption('Modem3','ATM'));
        option.add(new SelectOption('Modem4','VOIP'));
        option.add(new SelectOption('Modem5','Modem5'));
        return option;
    }

 

    public List<SelectOption> getItems2()
    {
          List<SelectOption> options = new List<SelectOption>();

          if( theValueimsearchingfor = 'VOIP){


          List<Product2> proList = [select name from Product2 where ProductCode like '0001-%'];
          for(product2 a : proList)
           options.add(new SelectOption(a.Name,a.Name));
        }
        return options;
    }

 

Apex Code:

 

<apex:selectList id="picklist1" title="Tipo" id="selectlist1" value="{!select1}" size="1">
        <apex:actionSupport event="onclick" reRender="selectlist2"/>
        <apex:selectOptions value="{!items}"/>    

</apex:selectList>

 

 <apex:selectList title="Marca" id="selectlist2" value="{!select2}" size="1">
        <apex:actionSupport event="onclick"  reRender="selectlist3"/>
        <apex:selectOptions value="{!items2}"/>    
 </apex:selectList>

  • August 13, 2010
  • Like
  • 0

Hi thanks for all the answers in advance.

 

My problem right now is the following :

 

I make the following SOQL to get some values of the product2 table. I need to DISTINCT them but currently SOQL doesnt have the functionallity. Im trying a work around and i wanted to know if it was posible.

 

 

Right now I have the following code:

 

 

 List<SelectOption> options = new List<SelectOption>();
         options.add(new SelectOption('N/A','N/A'));
         if (select2 == 'BP'){
           for(product2 tmp : [select minutes__c from product2 where sub_family_C = 'BP']{
                   for(Integer k = 0 ; k < tmp.size() ; k++){
                      if(tmp[k].minutes__c != tmp[k].minutes__c){
                          options.add(new SelectOption (tmp.minutes__C ,tmp.minutes__C));
                       }
               }
           }
         return options;

 

 

I cant seem to get it right. I just want to populate my product list and then traverse the list to find if the value is already there if it is then dont add it to the list.

 

Again thanks for all the help!.

  • September 07, 2010
  • Like
  • 0

hi im trying to get the string value out of a List<product2> ( list of products), So I can display it on a apex:outputtext.

 

 

Al the help is really appreciated.

 

 

My VF page Code :

 

 <apex:selectList title="Marca" id="selectlist2" value="{!select2}" size="1">
        <apex:actionSupport event="onclick" reRender="output"/>
        <apex:selectOptions value="{!items2}"/>    
        </apex:selectList>

 

<apex:outputText id="output"   style="font-style:italic" value="{0}" rendered="true" title="Producto">
        <apex:param value="{!items3}" />
</apex:outputText>

 

My controller Code:

 

    public List<SelectOption> getItems2()
    {
        List<SelectOption> options = new List<SelectOption>();
        if(select1 == 'Modem1'){
          List<Product2> proList = [select name from Product2 where ProductCode like '0001-%'];
          for(product2 a : proList)
           options.add(new SelectOption(a.Name,a.Name));
        }
        else if(select1 == 'Modem2'){
          List<Product2> proList = [select name from Product2 where ProductCode like '0000-%'];
          for(product2 a : proList)
          options.add(new SelectOption(a.Name,a.Name));
        }
        
        return options;
    }
    public List<Product2> getItems3()
    {
        List<Product2> proList = [select ProductCode from Product2 where name = :select2 limit 1];
        return prolist;
    }

 

I need to return a string value from my list :

 

       public String  getItems3()
    {
        List<Product2> proList = [select ProductCode from Product2 where name = :select2 limit 1];
        return prolist;
    }

  • August 19, 2010
  • Like
  • 0

I am new to this message board so my verbage may be a little off.  Please forgive me in advance and feel free to correct me as neccessary.

 

I'm having a problem with some custom objects I built.  I'm trying to control which fields are displayed in that custom object based on an individual record of another custom object.  So, for example, I have 900+ raw data records that need to be scored (internal method of scoring utilized, no lead scoring or Salesforce scoring method applies) in custom object A and five types of scoring methods in custom object B.  In this case, custom object A is, essentially, similar to a controlling picklist of custom object A.  Based on the individual record in custom object A, I would like ONLY one of the scoring methods in custom object B displayed to the end user.  There is no way to aggregate data form the 900+ records and then define the scoring method, but I wish there was because it would make it much easier.  It seems complex and I've tried to figure out a quicker way but this is the only path that the customer would like to proceed with.  Any ideas?  Is this related to APEX code or would this be Visual Force code?  I have a prompt deadline, so any help ASAP is much appreciated.  Thanks in advance.

Hi, I need help retrieving the option the user selected of a pre-determine values of a picklist I created. So my other indepedent picklist retrieves the value depending on the user first selection.

 

Thanks for all the Help you can give.

 

Here's the Code:

 

Controller Code:

 

    Public string select1{get; set;}
    Public string select2{get; set;}

 


    public List<SelectOption> getItems()
    {
        List<SelectOption> option = new List<SelectOption>(option); 
        option.add(new SelectOption('Modem1','Celulares'));
        option.add(new SelectOption('Modem2','Dmax'));
        option.add(new SelectOption('Modem3','ATM'));
        option.add(new SelectOption('Modem4','VOIP'));
        option.add(new SelectOption('Modem5','Modem5'));
        return option;
    }

 

    public List<SelectOption> getItems2()
    {
          List<SelectOption> options = new List<SelectOption>();

          if( theValueimsearchingfor = 'VOIP){


          List<Product2> proList = [select name from Product2 where ProductCode like '0001-%'];
          for(product2 a : proList)
           options.add(new SelectOption(a.Name,a.Name));
        }
        return options;
    }

 

Apex Code:

 

<apex:selectList id="picklist1" title="Tipo" id="selectlist1" value="{!select1}" size="1">
        <apex:actionSupport event="onclick" reRender="selectlist2"/>
        <apex:selectOptions value="{!items}"/>    

</apex:selectList>

 

 <apex:selectList title="Marca" id="selectlist2" value="{!select2}" size="1">
        <apex:actionSupport event="onclick"  reRender="selectlist3"/>
        <apex:selectOptions value="{!items2}"/>    
 </apex:selectList>

  • August 13, 2010
  • Like
  • 0

I have to Add Product Records from a Custom Package_Product__c Object that has lookup to Product2, into the Product Related list on Opportunity Detail Page 

I have Custom Link on the Opportunity Detail Page. This link Opens a VF Page with Drop downlist that contains records from a CUstom Object Package_Header__c (). Each Package have more than one records from the custom object Package_Products__c. When a user select the package from the Dropdown, all the products in the package are added to the Product Related List on the Opprotunity detail page.

I have completed the first part here, where I have inserted the Records Package_Header__c Records into the dropdown on the basis of Legal_entity__c field (it represent countries). Also I have queried the records from the custom Object Package_Products__c. But My main Problem is how to insert the records into Product Related List (This related list is Standard one and comes by default with every opportunity record and lists the products associated with the opportunity)

The coded for it is written below: I am using Extension = packageSelectionController  and Opportunity as Standard Controller

 

public class packageSelectionController {

public string legalEntity;

public Opportunity opp = new Opportunity();

public Package_Header__c pobj = new Package_Header__c();

public List<Package_Header__c> plist {get;set;}

 

public packageSelectionController(ApexPages.StandardController controller) {

String id = ApexPages.currentPage().getParameters().get('id'); opp = [

select Legal_Entity__c from Opportunity where id = :id];

legalEntity = opp.Legal_Entity__c;

plist = [select id, Name from Package_Header__c where Legal_Entity__c =: legalEntity];

}

 

//Create the picklist on the VF Page and populate it withy the records from Package_Header__c

String piValues;

public List<SelectOption> getItems(){

List<SelectOption> options = new List<SelectOption>();options.add(

new SelectOption(' ',' ')); for(Package_Header__c pobj1: plist)

{

options.add(new SelectOption(pobj1.id,pobj1.Name));

}

return options;

}

 

public String getPiValues(){ return piValues;

}

public void setPiValues(String selectedValue){ this.piValues = selectedValue;

}

 

public String getLegalEntity(){ return legalEntity;

}

//create a list of package products that holds the products for a particular package,(used in the SelectPackage method below)

public List<Package_Product__c> packageProduct = new List<Package_Product__c>();

public List<OpportunityLineItem> oplItem = new List<OpportunityLineItem>();

public PageReference SelectPackage(){

//Select the Required fields from the Package_Product__c Onthe basis of selected value of the picklist for Packages

String packageId = ApexPages.currentPage().getParameters().get(piValues);

packageProduct = [Select Id, Name, Quantity__c, Product2__c, Discount__c, Fixed_Price_Discount__c,

Sort_Order__c, Opt__c, Smpl__c, Product2__r.Id, Product2__r.ProductCode From Package_Product__c

Where Package_Header__c = :packageId ];

//variables for holding then field values from the

String productName;

String productCode;

String quantity;

String discount;

String fixedPrice;

String Opt;

 

//For loop for assigning the retieved values for each record in the above query to the variables declared above.

 for(Package_Product__c pkProd: packageProduct){oplItem.productName = packageProduct.Name;

oplItem.discount = packageProduct.Discount__c;

}

 

PageReference opportunityPage = new ApexPages.StandardController(opp).view();

opportunityPage.setRedirect(true);

return opportunityPage;

 

}

 

public PageReference cancel() {PageReference opportunityPage = new ApexPages.StandardController(opp).view();

opportunityPage.setRedirect(true);

return opportunityPage;

}

}

 

<!--  Code for Page -->

<apex:page standardController="Opportunity" extensions="packageSelectionController" tabStyle="Opportunity" sidebar="false" showHeader="true"  >
  <!-- Begin Default Content REMOVE THIS -->

  <apex:form >
 
  <div style="border: 1px solid red; padding-top:10px; padding-bottom:10px;">
  <apex:pageBlock rendered="true" title="You are Logged in as: {!$User.FirstName} {!$User.LastName}" >
 
  <apex:outputLabel value="Select Product Package from List: " for="packageList" style="font-family:Arial,Sans-Serif; line-height:10pt; font-size:11pt; margin-right:10px; "/><br/>
      <!-- This value parameter takes the name of the list -- getRequestTypeItems (without get) of type Select Options -->
    <br/>
  <apex:selectList value="{!piValues}" size="1">
      <apex:selectOptions value="{!items}"></apex:selectOptions>
  </apex:selectList>
 
 <br/>
 
 <apex:commandButton title="Select" value="Select" action="{!SelectPackage}"/>
 <apex:commandButton title="Cancle" value="Cancel" action="{!cancel}"/>
  </apex:pageBlock>
  </div>
  </apex:form>
  <!-- End Default Content REMOVE THIS -->
</apex:page>