function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Saikiran KolliSaikiran Kolli 

Unable to Add field values into dropdown list

Hi,

I'm having 15 boxes(Pick list) .I'm adding order line items into those 15 boxes... For ex: I'm selecting box 1 and adding values in supplied quantity field. and clicking on save.. when I select the box in other page values are not showing... but here in the previous page values are displaing  
public with sharing class bulkff {

 public String SelectedBox{Set;Get;}
 public List<Orders__c> order {get;set;} 
 List < Order_Line_Items__c > listOfItems ;
  public list<SelectOption> Boxoptions{set;get;}
  Public list<Order_Line_Items__c> orderItemsList{Set;Get;}
  set<String> lineItemName{Set;Get;}
  public String oid{get;set;}
  public String olit{get;set;}
  List < Order_Line_Items__c > list1;
   public Order_Line_Items__c OrdlItem{Set;Get;}
    
    public bulkff(){
    Boxoptions=new list<SelectOption>();
    lineItemName=new set<String>();
       orderItemsList=new list<Order_Line_Items__c>();
       OrderLineItems();
       String boxnm='';
        Boxoptions.add(new SelectOption('--None--', '--None--'));
        for(integer i=1;i<=15;i++)
        {
            boxnm = 'Box '+i;
            Boxoptions.add(new SelectOption(boxnm, boxnm));
        }
       }
     public void OrderLineItems(){
      Set<id> oid = new Set<id>();
        List < Order_Line_Items__c > listOfItems = new List < Order_Line_Items__c > ();
        order = [SELECT name, Total_supplied_quantity__c, Location__c, From_Date__c, To_Date__c, id, Status__c, Submitted_On__c, SystemModstamp, Total_Quantity__c, Total_Units__c FROM Orders__c Where Id = : apexPages.currentPage().getParameters().get('id') ];
        for(Orders__c o : order)
        {
            oid.add(o.id);
        }
      
      orderItemsList = [Select Id, Name, Difference__c, Order__c, Quantity__c, Select_Box__c, Supplied_Quantity__c, Type__c from Order_Line_Items__c where Order__c=:Apexpages.currentpage().getParameters().get('id') AND Compare__c = 'false'];
        for(Order_Line_Items__c old : orderItemsList)
        {
            
           if(old.Select_Box__c== '' || old.Select_Box__c == '--None--' || old.Select_Box__c == null ){
           ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please select Box to save'));
          
        }
 
        }
     
     
}

public void refresh()
{
if(SelectedBox=='' || SelectedBox==null || SelectedBox=='--None--')
       {
       
           ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please select Box to save'));
     
       }
       
       
}
     public pagereference updatevalue()
    {
       if(orderitemslist.size()>0)
        {
            update orderitemslist;
            OrderLineItems();
        }
  return new Pagereference('/apex/orderView?id='+order[0].id).setredirect(true); 
}    
}




<apex:page controller="bulkff" sidebar="false" id="page" tabStyle="Orders__c">

  <html>

<title>Print Test Page</title>

 <style type="text/css">
   .outBorder {
    border:3px outset black;
   }
   .inBorder{
    border-top:2px inset black;
    border-left:2px inset black;
   }
    
  </style>
  
 
<script>

function printDiv(divId) 
{
       var result = document.getElementById('page:form:pb1:pbstbl:pbsi:sl').value;
        if (result == "--None--") 
            {
                alert("Please Select Box");
            }
            else{
  
        window.frames["print_frame"].document.body.innerHTML=document.getElementById(divId).innerHTML;
        window.frames["print_frame"].window.focus();
        window.frames["print_frame"].window.print();
        }      
  }  
</script>

<body>

</body>

    
    <script src="{!URLFOR($Resource.jQuery,'')}"/>
    <script type="text/javascript">
       var j$ = jQuery.noConflict();
       
      
           function focusme()
           {
               var inpele = j$("input[id$='xyz']");
               inpele.val("");
               inpele.focus();
           }
       
    </script>
  
    <apex:outputPanel id="errorpanel">
    <apex:pageMessages id="showMsg" />
    </apex:outputPanel>
    <apex:form id="form">
        <apex:pageBlock title="Bulk Fulfill" id="pb1" >
            <apex:outputpanel id="panel">
            
                <apex:pageBlockSection columns="1">
                
                   <apex:pageBlockSectionItem >
                        <apex:outputLabel >Choose Box to Save</apex:outputLabel>
                       
                    </apex:pageBlockSectionItem>
        <apex:selectList value="{!SelectedBox}" size="1">
                    <apex:selectOptions value="{!Boxoptions}"></apex:selectOptions>
                </apex:selectList>
                </apex:pageBlockSection>
                
                <apex:pageBlockSection columns="1" >
                 <apex:outputField value="{!order[0].name}"/>
                 <apex:outputField value="{!order[0].Location__c}" />
          
     <br/>
             </apex:pageblocksection>
             
               </apex:outputpanel>
      
    <apex:outputPanel id="tblpnl">
    <div id="itemsDiv">
  
     <apex:pageblockTable value="{!orderItemsList}" border="1" var="ord" id="theTable" rowClasses="odd,even" styleclass="outBorder" width="550px" rendered="{!orderItemsList.size>0}">
    
          <apex:column styleclass="inBorder">
             <apex:facet name="header">Subject</apex:facet>
              <apex:outputText value="{!ord.Name}"/>
         </apex:column>
        
        <apex:column styleclass="inBorder">
              <apex:facet name="header">Quantity</apex:facet>
              <apex:outputText value="{!ord.Quantity__c}"/>
        </apex:column>
        <apex:column styleclass="inBorder" >
            <apex:facet name="header">Supplied Quantity</apex:facet>
            <apex:inputText value="{!ord.Supplied_Quantity__c}"/>
            <apex:actionSupport event="onchange" action="{!refresh}" onbeforedomupdate="beep()"  reRender="pbstbl,xyz,errorpanel,pb1" oncomplete="focusme();"></apex:actionSupport>
        </apex:column>
    
       

  </apex:pageblockTable>
  
</div>
</apex:outputPanel>

   <apex:pageBlockButtons location="top">
   <apex:commandButton value="Save Value" action="{!updatevalue}"/>
   
   </apex:pageBlockButtons>             
           
   

        </apex:pageBlock>
    </apex:form>
    </html> 
</apex:page>

 
Harish RamachandruniHarish Ramachandruni
public List<SelectOption> getCountries()
{
  List<SelectOption> options = new List<SelectOption>();
        
   Schema.DescribeFieldResult ple =
 OfficeLocation__c.Country__c.getDescribe();
        
   for( Schema.PicklistEntry f : ple)
   {
      options.add(new SelectOption(f.getLabel(), f.getValue()));
   }       
   return options;
}
Saikiran KolliSaikiran Kolli
Hi Harish,

Thanks for you reply, Need small help. When I'm trying to add values in box 1 which is a pick list I'm getting error. Could you please help me.

Page:


 <apex:outputLabel >Choose Box to Save</apex:outputLabel>
                       
                    </apex:pageBlockSectionItem>
        <apex:selectList value="{!SelectedBox}" size="1">

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

Constructor: 

public bulkff(){
    Boxoptions=new list<SelectOption>();
    lineItemName=new set<String>();
       orderItemsList=new list<Order_Line_Items__c>();
       OrderLineItems();
       String boxnm='';
        Boxoptions.add(new SelectOption('--None--', '--None--'));
        for(integer i=1;i<=15;i++)
        {
            boxnm = 'Box '+i;
            Boxoptions.add(new SelectOption(boxnm, boxnm));
        }
       }


Method: 

     public void OrderLineItems(){
      Set<id> oid = new Set<id>();
        List < Order_Line_Items__c > listOfItems = new List < Order_Line_Items__c > ();
        order = [SELECT name, Total_supplied_quantity__c, Location__c, From_Date__c, To_Date__c, id, Status__c, Submitted_On__c, SystemModstamp, Total_Quantity__c, Total_Units__c FROM Orders__c Where Id = : ApexPages.currentPage().getParameters().get('id') ];
        for(Orders__c o : order)
        {
            oid.add(o.id);
        }
      
      orderItemsList = [Select Id, Name, Difference__c, Order__c, Quantity__c, Select_Box__c, Supplied_Quantity__c, Type__c from Order_Line_Items__c where Order__c=:Apexpages.currentpage().getParameters().get('id')];
       
        
        for(Order_Line_Items__c old : orderItemsList)
        {
            
             //   selectedbox.add(orderItemsList);   

// Here I'm trying to add orderitemslist into a selected box but its throwing an error, Incorrect signature, I tried in all ways but its not working. Please help me
                     
             
        }
}



 
Harish RamachandruniHarish Ramachandruni




public bulkff(){


   
       }

public List<SelectOption> getBoxoptions()
{
  List<SelectOption> options = new List<SelectOption>();
        
 
        
    for(integer i=1;i<=15;i++)
        {
            boxnm = 'Box '+i;
            options.add(new SelectOption(boxnm, boxnm));
        }
   return options;
}

 

Add this one it will work .