• Girbson Bijou 8
  • NEWBIE
  • 70 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 18
    Questions
  • 5
    Replies
I Have a lookup relationship in  to the same object ( Articles_Containers__c). The lookup field is ParentItem__c. I need to display on a VF Page All parents and Child related to them  below them. 
I want to make sure that the child be right after their parent (in the next line as in the attached screenshot. For Now, the visualforce launch without error but it only display the parent records, but not the child. 
// Controller 

public class RGRPart1Controller {
    public Container__c container {get;set;}
    public Map<String,List<Articles_Containers__c>> ContainerItem{get;set;}
    String containerId;
    
    public RGRPart1Controller(){
    
    container = new Container__c();
        ContainerItem = new Map<String,List<Articles_Containers__c>>();
        
        try
        {
    
        containerId = ApexPages.currentPage().getParameters().get('id');
        container = [SELECT Id,Name,DR__c, PO__c,Arrived_Date__c, 
                     Invoice__c, Pkl__c, Description__c, 
                     Container__c.Provenance__c, Percent_Distributed__c, 
                     Bill_of_Lading__c, Size_in_feet__c, Seal_No__c, 
                         (SELECT Id,Name,Prod__c,Number__c,
                          Number_Distributed__c,Available__c,UM__c, Quantity__c,Unit_Of_Measure_Paking__c,
                          Pending__c, Percentagedistributed__c, Lot_Number__c ,Qty_Recieved_in_Paking_UoM__c,PrimaryDiscrepency__c,Action__c
                          FROM Articles_Containers__r WHERE ParentItem__c = NULL  )
                     FROM Container__c WHERE Id =:containerId];
        
          if(container != null)
            {
                Set<Id> articleContainersParentId = new Set<Id>();
                
                if(!container.Articles_Containers__r.isEmpty())
                {
                    for(Articles_Containers__c art :container.Articles_Containers__r)
                    {
                        articleContainersParentId.add(art.Id);
                        ContainerItem.put(art.Id, new List<Articles_Containers__c>());
                    }
                }
    
      List<Articles_Containers__c> lstChildArticleContainer = new List<Articles_Containers__c>();
                
                 lstChildArticleContainer = [SELECT Id,
                                                    Name,
                                                    Prod__c,
                                                    Number__c,
                                                    Number_Distributed__c,
                                                    Available__c,
                                                    UM__c,
                                                    Quantity__c, 
                                                    Pending__c, 
                                                    Percentagedistributed__c, 
                                                    Lot_Number__c, 
                                                    Qty_Recieved_in_Paking_UoM__c, 
                                                    PrimaryDiscrepency__c, 
                                                    Unit_Of_Measure_Paking__c,
                                                    Action__c 
                                               FROM Articles_Containers__c
                                               WHERE ParentItem__c IN : articleContainersParentId];
                                               
               if(!lstChildArticleContainer.isEmpty())
                {
                    for(Articles_Containers__c childItem :lstChildArticleContainer)
                    {
                        if(ContainerItem.containsKey(childItem.ParentItem__c))
                        {
                            ContainerItem.get(childItem.ParentItem__c).add(childItem);
                        }
                    }
                }
            }         
        }
        catch(Exception e)
        {
            System.debug(e.getMessage());
        }
    
}
}

The Body of the VF Page
//VF Page

<apex:page renderAs="pdf"  Controller="RGRPart1Controller"> 
 <table width="100%"> 
			 <tr> 
					 <th>Record ID</th> 
					 <th>Product</th>
					 <th>Qty Packing</th> 
					 <th>UOM Packing</th>
					 <th>Qty revieved in packing UoM</th> 
					 <th>Qty Recorded</th> 
					 <th>Uom Recorded</th> 
					 <th>Discrepencies</th>
					 <th>Action</th>
			 </tr> 
	 <apex:repeat var="c" value="{!container.Articles_Containers__r}"> 
			 <tr>
					 <td>{!c.Name}</td>
					 <td>{!c.Prod__c}</td>
					 <td>{!c.Quantity__c}</td>
					 <td>{!c.Unit_Of_Measure_Paking__c}</td>
					 <td>{!c.Qty_Recieved_in_Paking_UoM__c}</td>
					 <td>{!c.Number__c}</td>
					 <td>{!c.UM__c}</td>
					 <td>{!c.PrimaryDiscrepency__c}</td> 
					 <td>{!c.Action__c}</td> 
			 
			 </tr>
				 
		   <apex:repeat var="childItem" value="{!ContainerItem[c.Id]}"> 
			 <tr>
					 <td>--{!childItem.Name}</td>
					 <td>{!childItem.Prod__c}</td>
					 <td>{!childItem.Quantity__c}</td>
					 <td>{!childItem.Unit_Of_Measure_Paking__c}</td>
					 <td>{!childItem.Qty_Recieved_in_Paking_UoM__c}</td>
					 <td>{!childItem.Number__c}</td>
					 <td>{!childItem.UM__c}</td>
					 <td>{!childItem.PrimaryDiscrepency__c}</td> 
					 <td>{!childItem.Action__c}</td> 
			 </tr>
		   </apex:repeat>
	 </apex:repeat>
 </table> 
</apex:page>


User-added image
 
I need to implement a validation rule which should take effect  for all new record created after a specific date. I have a field called  Unit_Cost__c , this field can not be blank for all records created after  July 25, 2019. Below is a draft of my work.  The error message is: Syntax error. Missing ')'

AND(DateValue(CreatedDate)=>Date(2019, 07,25 ), 
(ISBLANK(  Unit_Cost__c  )))
Hi All ,
I follow the Steps in the  link below to filter data but i do not see the Button to Fetch the data when i load the visualforce page. 
https://blog.jeffdouglas.com/2010/07/13/building-a-dynamic-search-page-in-visualforce/

Help me please
<apex:page controller="allItems" sidebar="false">

  <apex:form >
  <apex:pageMessages id="errors" />
  
  <apex:pageBlock title="Find Me A Customer!" mode="edit">
    
  <table width="100%" border="0">
  <tr>  
    <td width="200" valign="top">
  
      <apex:pageBlock title="Parameters" mode="edit" id="criteria">
      
      <script type="text/javascript">
      function doSearch() {
        searchServer(
          document.getElementById("Product").value,
          document.getElementById("Comments").value,
          document.getElementById("Lot_Number").value,
          document.getElementById("centers").options[document.getElementById("technology").selectedIndex].value
          );
      }
      </script> 
      
      <apex:actionFunction name="searchServer" action="{!runSearch}" rerender="results,debug,errors">
          <apex:param name="Product" value="" />
          <apex:param name="lastName" value="" />
          <apex:param name="Lot_Number" value="" />
          <apex:param name="centers" value="" />
      </apex:actionFunction>
          
      <table cellpadding="2" cellspacing="2">
      <tr>
        <td style="font-weight:bold;">Product Name<br/>
        <input type="text" id="Product" onkeyup="doSearch();"/>
        </td>
      </tr>
      <tr>
        <td style="font-weight:bold;">Comments<br/>
        <input type="text" id="Comments" onkeyup="doSearch();"/>
        </td>
      </tr>
      <tr>
        <td style="font-weight:bold;">Lot Number<br/>
        <input type="text" id="Lot_Number" onkeyup="doSearch();"/>
        </td>
      </tr>
      <tr>
        <td style="font-weight:bold;">FFP Centers<br/>
          <select id="centers" onchange="doSearch();">
            <option value=""></option>
            <apex:repeat value="{!centerss}" var="tech">
              <option value="{!tech}">{!tech}</option>
            </apex:repeat>
          </select>
        </td>
      </tr>
      </table>
      
      </apex:pageBlock>
  
    </td>
    <td valign="top">
    
    <apex:pageBlock mode="edit" id="results">
                
        <apex:pageBlockTable value="{!allProduct}" var="allProd">
        
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Product Name" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="Product_Hiden_Name__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!allProd.Product_Hiden_Name__c}"/>
            </apex:column>
            
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Comments" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="Comments__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!allProd.Comments__c}"/>
            </apex:column>
            
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Lot_Number" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="Lot_Number__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!allProd.Lot_Number__c}"/>
            </apex:column>
            
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="centers" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="FFP_Centers__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!allProd.FFP_Centers__c}"/>
            </apex:column>
            
        </apex:pageBlockTable>
                
    </apex:pageBlock>
    
    </td>
  </tr>
  </table>
  
  <apex:pageBlock title="Debug - SOQL" id="debug">
      <apex:outputText value="{!debugSoql}" />           
  </apex:pageBlock>    
  
  </apex:pageBlock>

  </apex:form>

</apex:page>

Controller:   I get the following  in the  lines 61, 63, 65 when i use the quote ' ' in the Original post.
Compile Error: Found punctuation symbol or operator '%' that isn't valid in Apex. at line 61 column 85
public with sharing class allItems {
  
  // the soql without the order and limit
  private String soql {get;set;}
  // the collection of contacts to display
  public List<Articles_Containers__c> allProduct {get;set;}
  
  // the current sort direction. defaults to asc
  public String sortDir {
    get  { if (sortDir == null) {  sortDir = 'asc'; } return sortDir;  }
    set;
  }
  
  // the current field to sort by. defaults to last name
  public String sortField {
    get  { if (sortField == null) {sortField = '    FFP_Centers__c'; } return sortField;  }
    set;
  }
  
  // format the soql for display on the visualforce page
  public String debugSoql {
    get { return soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20'; }
    set;
  }

  // init the controller and display some sample data when the page loads
  public allItems() {
    soql = 'select Name ,Left_Warehouse_and_Delivered__c, Lot_Number__c, Expiration_Date__c, Product_Hiden_Name__c,FFP_Centers__c,Prod__c,UM__c, Container__c, Number__c, On_Hand__c,  Pending__c,  Available__c, Purpose__c, Condition__c, Age__c, Comments__c , Prod__c FROM Articles_Containers__c WHERE On_Hand__c >0  AND IsOpened__c = 1 ORDER BY FFP_Centers__c, Prod__c,UM__c ,Number__c';
    runQuery();
  }
  
  // toggles the sorting of query from asc<-->desc
  public void toggleSort() {
    // simply toggle the direction
    sortDir = sortDir.equals('asc') ? 'desc' : 'asc';
    // run the query again
    runQuery();
  }
  
  // runs the actual query
  public void runQuery() {
        
    try {
      allProduct = Database.query(soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20');
    } catch (Exception e) {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));
    }

  }
  
  // runs the search with parameters passed via Javascript
  public PageReference runSearch() {
    
    String Product = Apexpages.currentPage().getParameters().get('Product_Hiden_Name__c');
    String Comments = Apexpages.currentPage().getParameters().get('Comments__c');
   String Lot_Number = Apexpages.currentPage().getParameters().get('Lot_Number__c');
    String centers = Apexpages.currentPage().getParameters().get('FFP_Centers__c');
    
    soql = 'select Name ,Left_Warehouse_and_Delivered__c, Lot_Number__c, Expiration_Date__c, Product_Hiden_Name__c,FFP_Centers__c,Prod__c,UM__c, Container__c, Number__c, On_Hand__c,  Pending__c,  Available__c, Purpose__c, Condition__c, Age__c, Comments__c , Prod__c FROM Articles_Containers__c WHERE On_Hand__c >0  AND IsOpened__c = 1 ORDER BY FFP_Centers__c, Prod__c,UM__c ,Number__c';
   if (!Product.equals(''))
    soql += ' and Product LIKE "+String.escapeSingleQuotes(Product_Hiden_Name__c)+"%';
   if (!Comments.equals(''))
   soql += ' and Comments__c LIKE "+String.escapeSingleQuotes(Comments__c)+"%';
   if (!Lot_Number.equals(''))
     soql += 'and Lot_Number__c LIKE "+String.escapeSingleQuotes(Lot_Number__c)+"%';  
    if (!centers.equals(''))
      soql += 'and FFP_Centers__c includes ("+centers+")';

    // run the query again
    runQuery();

    return null;
  }
  
  // use apex describe to build the picklist values
  public List<String> centerss {
    get {
      if (centerss == null) {
              
        centerss = new List<String>();
        Schema.DescribeFieldResult field = Articles_Containers__c.FFP_Centers__c.getDescribe();
            
        for (Schema.PicklistEntry f : field.getPicklistValues())
          centerss.add(f.getLabel());
          
      }
      return centerss;          
    }
    set;
  }

}

​​​​​​​
Hi want to know if a record is already printed. I have a check box field called IsPrinted And a Visualforce page with a standard Controller. This VF page is rendered as PDF. Please help me to update the field 'IsPrinted'   when i print the page. Thanks 
Here is a portion of  my page
<apex:page renderAs="PDF"  readOnly="true" showHeader="false" sidebar="false"  applyHtmlTag="false"   standardStylesheets="false"  standardController="Delivery__c"  applyBodyTag="false" >    

    
    
    <!--<apex:stylesheet value="{!$Resource.CSSPrintPageDistrib}" />-->
    <div class="header">        
        <div class="col logo">
            <apex:image url="{!$Resource.LogoFFP}" width="140" height="60"/>
        </div>
        <div class ="col name"> 
            <h2>
                COMPANY Name
            </h2>           
            <h6>
                 {!Delivery__c.Beneficiaire__r.Parent.Distribution_Center__c} , 
                {!Delivery__c.Beneficiaire__r.Parent.Address__c }
                 Tels: {!Delivery__c.Beneficiaire__r.Parent.Phone} 
            </h6>
        </div>  
         <h4>DELIVERY ORDER</h4>
    <div class="firstBlock" > 
        
        <div class ="SubfirstBlock">
            <div>
                <b> Code:  {!Delivery__c.Name} </b>
            </div>
            <div>
                <b>Prochaine Livraison:</b>------------------------ 
            </div>
        </div>
        <div class ="SubfirstBlock">
            <div>
                <b>Status  :</b> {!Delivery__c.Delivery_status__c}  &nbsp;&nbsp; {!Delivery__c.Control_Status__c}     
            </div>
            <div>
                <b> Created By:</b> {!Delivery__c.CreatedBy.FirstName} {!Delivery__c.CreatedBy.LastName} <apex:outputtext value="{0, date, short}">
        <apex:param value="{!Delivery__c.CreatedDate}"></apex:param>  </apex:outputtext> <br/>
            </div>
        </div>
    </div>   
        <div class = "beneInfo">
        <div class ="tableBeneinfo">
            <b> Recipient Code : {! Delivery__c.Beneficiaire__r.Ext_ID__c} <br/></b>
            <b>Name   :</b> {!Delivery__c.Beneficiaire__r.Name}   <br/> 
            <b>Contact Pers.    :</b> {!Delivery__c.RepresentantBenficiaire__c}<br/>
            <b>Telephone    :</b> {!Delivery__c.Beneficiaire__r.Phone}<br/>
        </div>  
        <div class ="tableBeneinfo">
            <b>Category   :</b> {!Delivery__c.Beneficiaire__r.Type}<br/> 
            <b>Departement  :</b> {!Delivery__c.Beneficiaire__r.Departement__c} <br/>
            <b>Region  :</b> {!Delivery__c.Beneficiaire__r.Commune__c}   <br/>     
            <b>Benef.   :</b> {!Delivery__c.Beneficiaire__r.Number_of_Beneficiaries__c} <br/> 
             <b>Comments  :</b>  {!Delivery__c.Comments__c}
               
        </div>
    </div>
        
    </div> 
    
    
    <div class="footer" >    

               Printed by :  {!$User.FirstName} {!$User.LastName} <apex:outputtext value="{0, date, long}">
        <apex:param value="{!NOW()}"></apex:param>
    </apex:outputtext> <br/>
            As often as you did it for one of my  least brothers, you did it for me. Matthiew 25:40 <br/>
            <div>Page <span class="pagenumber"/> of <span class="pagecount"/></div>
     
        </div>
     
    <br/>
  
    <div class="table">
        
        <div class="tableHeader">       
            <th>ID </th> 
            <th>Product  </th> 
            <th>Quantity </th> 
            <th>UM </th> 
            
        </div>
        
        <apex:repeat var="c"  value="{!Delivery__c.Items_distributed__r}"> 
         <!--  <div class="tablebody"> -->
               <tr >
                
                <td>{!c.Product__r.Name}</td>
                <td>{!c.Productt__c}</td> 
                <td>{!Text(c.Quantity__c)}</td>
                <td>{!c.UM__c}</td>
            </tr> 
            <!--</div> -->
        </apex:repeat>
        
            <div class ="recommendation">
      
        En recevant ces articles, vous consentez à:<br/> 
        - ne pas les vendre <br/> 
        - maintenir des archives pouvant etre consultées a tout moment<br/>
        - les utiliser uniquement au benefice des plus pauvres <br/> 
        - accorder l'acces a vos depots en tout temps aux inspecteurs de Food For the Poor. <b/> <b/> 
        .
    </div>
                  
           <div class ="signature" >
        
        <div class="tableBeneinfo">
            
            <div>Authorized Signature </div>
            <br/> 
            <br/>
           
            <div>Delivered by </div><div> Date</div>
            <br/> 
            <br/>
            
            <div>Received by &nbsp;&nbsp;   </div><div>   &nbsp;&nbsp; Date  &nbsp;&nbsp;</div>
            <br/> 
            <br/>
            
        </div>
        <div class="tableBeneinfo">
            
            <div>Controlled by </div><div> Date </div>
            <br/> 
            <br/>
            
            <div>Register by </div><div> Date</div>
            <br/> 
            <br/>
                                                                                                 
            <div>Vehicule information </div><div> Date</div>
            
             
        </div>
    </div>
    </div>
    
    
</apex:page>

 
Help to solve this please: Illegal assignment from Decimal to String at line 34 column 4 in the test class
public with sharing class InventorySearchController { 
public list <Articles_Containers__c> inventoryItem {get;set;} 
public string searchstring {get;set;} 
public InventorySearchController( ) { 
} 
public void search(){ 
string searchquery= 'select Name , FFP_Centers__c,Prod__c, UM__c, Container__c, Number__c, On_Hand__c,  Pending__c,  Available__c, Purpose__c, Condition__c, Age__c, Comments__c FROM Articles_Containers__c  WHERE Prod__c like \'%'+searchstring+'%\'  AND On_Hand__c >0  AND IsOpened__c = 1  ORDER BY FFP_Centers__c, Prod__c,UM__c Number__c Limi 1000';
     
      inventoryItem= Database.query(searchquery); 

}
public void clear(){ 
inventoryItem.clear(); 
} 
}


@isTest
private class InventorySearchController_Test{
  @testSetup
  static void setupTestData(){
     test.startTest();
    Account pa = new Account(Name ='test Account parent', Representant__c ='hkjlhjd', 
    Distribution_Center__c='CRD Cayes', Class__c = 'Clinic', Type = 'CLINICS', 
    Departement__c = 'NORD', Address__c ='Test Address');
    insert pa;
    
          Product2 p = new Product2(Name ='TestProduct'); 
          insert p;
          Container_Shipper__c cs =new Container_Shipper__c(Name = 'Test Shipper');
          insert cs;
    Container__c container_Obj = new Container__c(Provenance__c = 'FFP FLORIDA', Distribution_Center__c= pa.id, Statut__c = 'Open',  FFP_Centers__c = 'FFP Caracole', 
     RecordTypeId='0126A000000nMlU',  Shipper__c=cs.Id );
    Insert container_Obj; 
    Articles_Containers__c articles_containers_Obj = new Articles_Containers__c(Container__c = container_Obj.id, Number__c = 17, UM__c = 'BAG(S)' ,  Local_ID__c = 7888, Product__c=p.ID,
            Comments__c = 'UNIT(S)',
           Purpose__c='Consignment',
            Condition__c= 'New',
           FFP_Centers__c = 'FFP Caracole'
            );
    Insert articles_containers_Obj; 
    test.stopTest();
  }
  static testMethod void test_search_UseCase1(){
    List<Container__c> container_Obj  =  [SELECT Provenance__c,Statut__c,Is_Reported__c,FFP_Centers__c  from Container__c];
    System.assertEquals(true,container_Obj.size()>0);
    List<Articles_Containers__c> articles_containers_Obj  =  [SELECT Container__c,Number__c,UM__c from Articles_Containers__c];
    System.assertEquals(true,articles_containers_Obj.size()>0);
    InventorySearchController obj01 = new InventorySearchController();
    obj01.inventoryItem = articles_containers_Obj;
 //Illegal assignment from Decimal to String at line 34 column 4      
obj01.searchstring =  articles_containers_Obj[0].Number__c;
    obj01.search();
  }
  static testMethod void test_clear_UseCase1(){
    List<Container__c> container_Obj  =  [SELECT Provenance__c,Statut__c,Is_Reported__c,FFP_Centers__c from Container__c];
    System.assertEquals(true,container_Obj.size()>0);
    List<Articles_Containers__c> articles_containers_Obj  =  [SELECT Container__c,Number__c,UM__c from Articles_Containers__c];
    System.assertEquals(true,articles_containers_Obj.size()>0);
    InventorySearchController obj01 = new InventorySearchController();
    obj01.inventoryItem = articles_containers_Obj;
   // obj01.searchstring = articles_containers_Obj[0].Number__c;
    obj01.clear();
  }
}

 
Hi all, Help me please. 
I want display a field value of a Rich text area in a Visualforce as it is formated in the layout. The must important for me is to go on the next line like in the first screenshot. 
Here is my portion of code

<p style="border: 0.08px solid black;"> {!Container__c.General_Comments__c}</p>
User-added image
Please help me to display more than 1000 lines in a visualforce page.
public class InventoryCentralOficce {

      public List<AggregateResult> allproduct{get;set;}

     public InventoryCentralOficce() {

   allproduct = [
      
  SELECT Product_Hiden_Name__c, UM__c ,SUM(On_Hand__c)onHand,  SUM(Pending__c)pending,  SUM(Available__c)avail 
      FROM Articles_Containers__c 
      WHERE IsOpened__c = 1 AND FFP_Centers__c = 'Central Office'
GROUP BY Product_Hiden_Name__c , UM__c 
HAVING SUM(On_Hand__c) >0 
ORDER BY Product_Hiden_Name__c, UM__c limit 50000];
      
      

      }
}

 
Help me to use the User time instead of GMT Time
<div class="footer">
        <div>
                 Printed by :  {!$User.FirstName} {!$User.LastName} &nbsp; 
                   <apex:outputtext value=" {0, date, long} ">
                       <apex:param value=" {!NOW()} "></apex:param>
                  </apex:outputtext> &nbsp; at {!TIMENOW()}
                  <div>Page <span class="pagenumber"/> of <span class="pagecount"/></div>
       </div>
</div>
Hi all, 
Help me to increment a field by 1 based a picklist value of an other field. 
Like below. 
I mean, i have different Location, the auto number should be incremented by location. 

My sObject is: Delivery
Location Name: Location
field to incremented :Number__c
User-added image

 
I need to search data in a visualforce with criteria from multiple field.
The field which will be used as Critieria are:
Purpose__c  : Picklist
Condition__c : Picklist
Prod__c : Text
UM__c: Picklist
Container__c: Text

the code below allow me to set criteria for one field. Help me to improve it.
public with sharing class InventorySearchController { 
public list <Articles_Containers__c> inventoryItem {get;set;} 
public string searchstring {get;set;} 
public InventorySearchController( ) { 
} 
public void search(){ 
string searchquery= 'select Name , Prod__c, UM__c, Container__c, Number__c, On_Hand__c,  Pending__c,  Available__c, Purpose__c, Condition__c, Age__c, Comments__c FROM Articles_Containers__c  WHERE Prod__c like \'%'+searchstring+'%\'  AND On_Hand__c >0  AND IsOpened__c = 1  Limit 50000';
     
      inventoryItem= Database.query(searchquery); 

}
public void clear(){ 
inventoryItem.clear(); 
} 
}

// VF
<apex:page Controller="InventorySearchController"  Sidebar="False"> 
<apex:form > 
<apex:inputText value="{!searchstring}" label="Input"/> 
<apex:commandButton value="Search records" action="{!search}"/> 
<apex:commandButton value="Clear records" action="{!clear}"/> 
<apex:pageBlock title="Search Result"> 
<apex:pageblockTable value="{!inventoryItem}" var="a"> 

<apex:column value="{!a.Name}"/> 
<apex:column value="{!a.Prod__c}"/> 
<apex:column value="{!a.UM__c}"/> 
<apex:column value="{!a.Container__c}"/> 
<apex:column value="{!a.Number__c}"/> 
<apex:column value="{!a.On_Hand__c}"/> 
<apex:column value="{!a.Pending__c}"/> 
<apex:column value="{!a.Available__c}"/> 
<apex:column value="{!a.Purpose__c}"/> 
<apex:column value="{!a.Condition__c}"/> 
<apex:column value="{!a.Age__c}"/> 
<apex:column value="{!a.Comments__c}"/> 
</apex:pageBlockTable> 
</apex:pageBlock> 
</apex:form> 
</apex:page>


 
I need to create Multiple Child Records from Parent Related List but i get the Error: "URL No Longer Exists" but the data saved in the database. Also, it seem that the Parent Id does not populate autonmatically so, i have to add it manually. I want to notice that I add the child page as a related list of the parent. The Parent Obejct is Devery__c, the child is Item_Distributed__c Here is my code:
public class AddOrderItem {

    public String Delivery { get; set; }
Id DeliveryId;
public List<Item_Distributed__c> listOrderItem {get;set;}
public Integer rowNum{get;set;}

public AddOrderItem(ApexPages.StandardController controller){
   Id OrderItemId = ApexPages.currentPage().getParameters().get('OrderItemId');
    DeliveryId=ApexPages.currentPage().getParameters().get('DeliveryId');
    listOrderItem = new List<Item_Distributed__c>();
    listOrderItem.add(new Item_Distributed__c());

}

public pagereference insertOrderItem(){
    insert listOrderItem;
    Pagereference page=new pagereference('/'+DeliveryId);
    Return page;
}

public void insertRow(){
    listOrderItem.add(new Item_Distributed__c());
}

public void delRow(){
    rowNum = 
Integer.valueof(apexpages.currentpage().getparameters().get('index'));
    listOrderItem.remove(rowNum);
}
}

//VF Page

<apex:page StandardController="Delivery__c"  Extensions="AddOrderItem" showHeader="false" sidebar="false" >
<apex:form >
    <apex:variable var="rowNum" value="{!0}" />
    <apex:pageBlock >
        <apex:variable var="rowNum" value="{!0}" />
        <apex:PageBlockTable value="{!listOrderItem}" var="int">
        <apex:facet name="footer">
            <apex:commandLink value="Add" action="{!insertRow}"/>
            </apex:facet>
            <apex:column headerValue="Quantity">
                <apex:inputField value="{!int.Quantity__c}"/>                                      
            </apex:column>
            <apex:column headerValue="Product">
            <apex:inputField value="{!int.Product__c}"/> 
            </apex:column>
         <apex:column headerValue="Product">
            <apex:inputField value="{!int.Delivery__c}"/> 
            </apex:column>  
             <apex:column headerValue="Delete">
            <apex:commandLink style="font-size:15px; font-weight:bold; text-align:center;color:red;" value="X" action="{!delRow}">
                <apex:param value="{!rowNum}" name="index"/>
                </apex:commandLink>
                <apex:variable var="rowNum" value="{!rowNum+1}"/>
            </apex:column>
        </apex:PageBlockTable>
    <apex:pageBlockButtons >
        <apex:commandButton value="Save" action="{!insertOrderItem}"/>
        </apex:pageBlockButtons>
    </apex:pageBlock>

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

User-added image
I have an Object Called Container__c with a child called Article__Container__c. I create a visualforce page to display all child with an Extension Controller. But when i Hit the button on the layout page it display all the child in the database not the ones related to the specific parent record. 
//Extention Controller

public class RgrReportControllerExt {
      public List<AggregateResult> allproduct{get;set;}
      public RgrReportControllerExt(ApexPages.StandardController controller) {

      allproduct = [
      SELECT UM__c uom,SUM(Number__c)qtyReceived,  SUM(Quantity__c)qtyPaking,  
      SUM(PrimaryDiscrepency__c)Discrep FROM Articles_Containers__c    
      GROUP BY  UM__c 
      ORDER BY  UM__c limit 1000];    
}
}

// portion of my VF Page
<apex:page RenderAs="PDF" showHeader="false" sidebar="false"  applyBodyTag="false" standardStylesheets="True" standardController="Container__c" Extensions="RgrReportControllerExt">

<b> Description of Goods</b> : <u>{!Container__c.Description__c}</u> <br/>
 (Descripción de bienes) <br/> <br/>
 
 <div class="firstBlock" >        
            <div class ="SubfirstBlock">     
                <div>
                    <table style="width:100%;border-collapse: collapse; border: 0.5px solid black;"> 
                             <tr >
                                     <th>UoM</th> 
                                     <th>Expected</th>
                                     <th>Actual</th>
                                     <th>Descrepencies</th>  
                             </tr> 
                             
                                  <apex:repeat value="{!allproduct}" var="row">
                                    <tr >
                                      <td>{!row['uom']}</td>
                                      <td>{!row['qtyPaking']}</td>
                                      <td>{!row['qtyReceived']}</td>
                                      <td>{!row['Discrep']}</td> 
                                    </tr>
                                </apex:repeat>
                      </table>   
                </div>   
           </div>

            <div class ="SubfirstBlock">
                <div>
                   
                </div> 
            </div>
        
            <div class ="SubfirstBlock">
                <div>
                  
                </div>            
            </div>   
    </div>
</apex:page>

 
My code are saved without error but the chart does not display in the VF page

portion of the VF page: 
<apex:page renderAs="pdf" showHeader="false" sidebar="false" applyBodyTag="false" standardStylesheets="True" Controller="ContainerGlobalShipmentController"> 
    
        <div class="head">        
            <div class="col logo">
                <apex:image url="{!$Resource.LogoFFP}" width="140" height="60"/>
            </div>
            <div class ="col name"> 
                <h2>
                    FOOD FOR THE POOR - HAITI
                </h2>           
                <h6>
                    14, Mapou Rte. Nationale #1, Cap Haitien, Haiti <br/>
                    Tels:(+509)2208-9960/3409-5328
                </h6>
            </div>        
        </div>
        
        <div class="firstBlock" > 
            
            <div class ="SubfirstBlock">
                 
                    <b><i>Total Containers:   {!TotalContainer}</i></b> <br/>
                     Containers In Transit :  {!AwaitingArrival} <br/>
                     Containers at Wharf:   {!ContainerAtWharf} <br/>
                     Containers at Warehouse  :  {!ContainerAtWarehouse}<br/>
                     Containers Returned to wharf last 5 Days   :  {!departed}  
            </div>
            
            <div class ="SubfirstBlock">
              
                <div>
                    <h2>Shipment Update  &nbsp; <apex:outputtext value="{0, date, long}">
            <apex:param value="{!NOW()}"></apex:param>
        </apex:outputtext>  </h2>
                </div>
                
            </div>
        </div>
         <br/>   
         //Chart
         <apex:chart height="350" width="450" data="{!pieData}">
            <apex:pieSeries dataField="data" labelField="name"/>
            <apex:legend position="right"/>
        </apex:chart> 
        
     <table style="width:100%;border-collapse: collapse; border: 0px solid black;"> 
     <tr> 
     <th>System Code</th> 
     <th>Ref#</th> 
     <th>Lead/PO</th>
     <th>Invoice#</th>
     <th>Container#</th>  
     <th>Size</th>
     <th>Shipper</th> 
     <th>Description</th> 
     <th>Bill of Lading No</th>
     <th>On Wharf</th>
     <th>Sailing</th>  
     <th>ETA</th>
     <th>Demurrage</th> 
     <th>Broker</th> 
     <th>Consignee</th> 
     </tr> 
     <apex:repeat var="key" value="{!Records}"> 
     
       <tr><th style="background: Gray; color:white; text-transform:uppercase;"><b> {!key}</b></th>
          <th style="background: Gray; color:white; text-transform:uppercase;"><b> </b></th>
          <th style="background:  Gray; color:white; text-transform:uppercase;"><b> </b></th>
          <th style="background: Gray; color:white; text-transform:uppercase;"><b> </b></th>
          <th style="background:  Gray; color:white; text-transform:uppercase;"><b> </b></th>
          <th style="background: Gray; color:white; text-transform:uppercase;"><b> </b></th>
          <th style="background:  Gray; color:white; text-transform:uppercase;"><b> </b></th>
          <th style="background: Gray; color:white; text-transform:uppercase;"><b> </b></th>
          <th style="background:  Gray; color:white; text-transform:uppercase;"><b> </b></th>
          <th style="background: Gray; color:white; text-transform:uppercase;"><b> </b></th>
          <th style="background:  Gray; color:white; text-transform:uppercase;"><b> </b></th>
          <th style="background: Gray; color:white; text-transform:uppercase;"><b> </b></th>
          <th style="background:  Gray; color:white; text-transform:uppercase;"><b> </b></th>
          <th style="background: Gray; color:white; text-transform:uppercase;"><b> </b></th>
          <th style="background:  Gray; color:white; text-transform:uppercase;"><b> </b></th>
      </tr>
    
    
    
      <apex:repeat value="{!Records[key]}" var="c">
     
       <tr>
     <td style="border: 0.08px solid gray;">{!c.ID_Container__c}</td>
     <td>{!c.Pkl__c}</td>
     <td>{!c.PO__c}</td>
     <td>{!c.Invoice__c}</td>
     <td>{!c.Name}</td>
     <td>{!c.Size_in_feet__c}</td>
     <td>{!c.Shipper__r.Name} </td>
     <td>{!c.Description__c}</td>
     <td>{!c.Bill_of_Lading__c}</td>
     <td>{!c.On_Wharf_Date__c}</td>  
     <td>{!c.Sailing__c}</td>
     <td>{!c.ETA__c} </td>
     <td>{!c.Demurrage_begins__c}</td>
     <td>{!c.Brocker__c}</td>
     <td>{!c.Consignee__c}</td> 
     
     </tr>
      </apex:repeat>
     </apex:repeat>
     </table>
     <h4><center> <i><b>List of containers returned to wharf during the last 5 days</b></i></center></h4><br/>
     <table style="width:100%;border-collapse: collapse; 
    }"> 
     <tr> 
     <th style="background: gray; color:white;">System Code</th> 
     <th style="background: gray; color:white;">Ref#</th> 
     <th style="background: gray; color:white;">Lead/PO</th>
     <th style="background: gray; color:white;">Invoice#</th>
     <th style="background: gray; color:white;">Container#</th>  
     <th style="background: gray; color:white;">Size</th>
     <th style="background: gray; color:white;">Shipper</th> 
     <th style="background: gray; color:white;">Description</th> 
     <th style="background: gray; color:white;">Bill of Lading No</th>
     <th style="background: gray; color:white; ">On Wharf</th>
     <th style="background: gray; color:white; ">Returned to Wharf</th>
     <th style="background: gray; color:white; ">Sailing</th>  
     <th style="background: gray; color:white; ">ETA</th>
     <th style="background: gray; color:white; ">Demurrage</th> 
     <th style="background: gray; color:white; ">Broker</th> 
     <th style="background: gray; color:white; ">Consignee</th> 
     </tr> 
     <apex:repeat var="d" value="{!lstDepartedLast5Days}"> 
     
     <tr>
     <td>{!d.ID_Container__c}</td>
     <td>{!d.Pkl__c}</td>
     <td>{!d.PO__c}</td>
     <td>{!d.Invoice__c}</td>
     <td>{!d.Name}</td>
     <td>{!d.Size_in_feet__c}</td>
     <td>{!d.Shipper__r.Name} </td>
     <td>{!d.Description__c}</td>
     <td>{!d.Bill_of_Lading__c}</td>
     <td>{!d.On_Wharf_Date__c}</td> 
     <td><apex:outputtext value="{0, date, long}">
            <apex:param value="{!d.Date_Return_to_wharf__c }"></apex:param>
        </apex:outputtext></td>
     <td>{!d.Sailing__c}</td>
     <td>{!d.ETA__c} </td>
     <td>{!d.Demurrage_begins__c}</td>
     <td>{!d.Brocker__c}</td>
     <td>{!d.Consignee__c}</td> 
     
     </tr>
     </apex:repeat>
     </table> 
     
     
     
      <div class="footer">
            <div>
               
                Printed by :  {!$User.FirstName} {!$User.LastName} &nbsp; 
                 <apex:outputtext value="{0, date, long}">
            <apex:param value="{!NOW()}"></apex:param>
        </apex:outputtext> &nbsp; at {!TIMENOW()} &nbsp; GMT <br/>
                As often as you did it for one of my  least brothers, you did it for me. Matthiew 25:40 <br/>
                  </div>
        </div>   
           
     
    </apex:page>

// Controller

    public class ContainerGlobalShipmentController{
    
        
        public integer AwaitingArrival { get; set; }
        public integer waitintingForClearance { get; set; }
        public integer readyToGoWarehouse { get; set; }
        public integer notOffload{ get; set; }
        public integer offload { get; set; }
        public integer departed { get; set; }
        public integer ContainerAtWharf { get; set; }
        public integer TotalContainer { get; set; }
        public integer  ContainerAtWarehouse { get; set; }
         
        
        public String Account { get; set; }
        
        public List<Container__c> lstDepartedLast5Days { get; set; }
        public Map<String, List<Container__c>> Records { get; set; }
        public ContainerGlobalShipmentController() {
        
        //ContainerAtWharf = [SELECT COUNT() FROM Container__c  WHERE Provenance__c ='FFP FLORIDA' AND Shipment_Status__c ='B - WAITING FOR CUSTOMS CLEARANCE' AND Shipment_Status__c ='C - READY TO GO TO WAREHOUSE'];
        
        
        AwaitingArrival =         [SELECT COUNT() FROM Container__c  WHERE Provenance__c ='FFP FLORIDA' AND Shipment_Status__c ='A - AWAITING ARRIVAL' ];
        waitintingForClearance =  [SELECT COUNT() FROM Container__c  WHERE Provenance__c ='FFP FLORIDA' AND Shipment_Status__c ='B - WAITING FOR CUSTOMS CLEARANCE'];
        readyToGoWarehouse=       [SELECT COUNT() FROM Container__c  WHERE Provenance__c ='FFP FLORIDA' AND Shipment_Status__c ='C - READY TO GO TO WAREHOUSE'];
        notOffload=               [SELECT COUNT() FROM Container__c  WHERE Provenance__c ='FFP FLORIDA' AND Shipment_Status__c ='D - AT WAREHOUSE(NOT OFFLOAD)'];
        offload =                 [SELECT COUNT() FROM Container__c  WHERE Provenance__c ='FFP FLORIDA' AND Shipment_Status__c ='E - AT WAREHOUSE(OFFLOAD)'];
        departed =                [SELECT COUNT() FROM Container__c  WHERE (    Date_Return_to_wharf__c =LAST_N_DAYS:5 
                                                                            AND Provenance__c ='FFP FLORIDA' 
                                                                            AND Shipment_Status__c='F - RETURNED TO WHARF')];
        
        ContainerAtWharf =  waitintingForClearance + readyToGoWarehouse;
        ContainerAtWarehouse = offload + notOffload;
        TotalContainer =ContainerAtWharf + departed + AwaitingArrival + ContainerAtWarehouse;
        
         
         Records = new Map<String, List<Container__c>>();
         Container__c [] results = [SELECT  Shipment_Status__c , Shipper__r.Name , Pkl__c, PO__c, Invoice__c,Name, Size_in_feet__c, Description__c, 
                                Bill_of_Lading__c,On_Wharf_Date__c,Sailing__c,ETA__c,Demurrage_begins__c,Brocker__c,Comments__c,     
                                ID_Container__c,  Consignee__c, Provenance__c
                                FROM Container__c    
                                WHERE (Provenance__c ='FFP FLORIDA' AND Shipment_Status__c !='F - RETURNED TO WHARF')];
                              
             
             lstDepartedLast5Days = [SELECT  Shipment_Status__c ,   Date_Return_to_wharf__c, Shipper__r.Name , Pkl__c, PO__c, Invoice__c,Name, Size_in_feet__c, Description__c, 
                                Bill_of_Lading__c,On_Wharf_Date__c,Sailing__c,ETA__c,Demurrage_begins__c,Brocker__c,Comments__c,     
                                ID_Container__c,  Consignee__c, Provenance__c
                                FROM Container__c    
                                WHERE ( Date_Return_to_wharf__c =LAST_N_DAYS:5 
                                AND Provenance__c ='FFP FLORIDA' 
                                AND Shipment_Status__c='F - RETURNED TO WHARF')];
                                
    
          for(Container__c result: results) {
                String status = result.Shipment_Status__c ;
                if(!Records.containsKey(status)) {
                 Records.put(status, new Container__c[0]);
                }
          Records.get(status).add(result); 
          }
        }
        //Chart
        public List<PieWedgeData> getPieData() {
            List<PieWedgeData> data = new List<PieWedgeData>();
            data.add(new PieWedgeData('Containers In Transit', AwaitingArrival));
            data.add(new PieWedgeData('Containers at Wharf', ContainerAtWharf));
            data.add(new PieWedgeData('Containers at Warehouse : 1', ContainerAtWarehouse));
            data.add(new PieWedgeData('Containers Returned to wharf last 5 Days', departed));
                   return data;
        }
    
        // Wrapper class
        public class PieWedgeData {
    
            public String name { get; set; }
            public Integer data { get; set; }
    
            public PieWedgeData(String name, Integer data) {
                this.name = name;
                this.data = data;
            }
        }
        
    }

 
Hi  All, I want group record by the  field named Shipment_Status__c  as attached.  I get the error "only aggregate expressions use field aliasing"
Here the controller
public class ContainerGlobalShipmentController{
public Map<String, List<Container__c>> Records { get; set; }
public ContainerGlobalShipmentController() {
 Records = new Map<String, List<Container__c>>();
 Container__c [] results =
[SELECT  Shipment_Status__c status, Pkl__c, PO__c, Invoice__c,Name, Size_in_feet__c, Description__c, 
Bill_of_Lading__c,On_Wharf_Date__c,Sailing__c,ETA__c,Demurrage_begins__c,
Brocker__c,Comments__c,     ID_Container__c,  Consignee__c, Provenance__c
 FROM Container__c WHERE (Departed_to_Wharf_Date__c = NULL OR 
 (Departed_to_Wharf_Date__c =LAST_N_DAYS:5))   
 AND Provenance__c ='FFP FLORIDA'];
 
  for(Container__c result: results) {
     status = (String)result.get('status');
    if(!Records.containsKey(status)) {
      Records.put(status, new Container__c[0]);
    }
    Records.get(status).add(result);
  }
}
}

User-added image
Help to arrange the data in this page. I need tou group the Inventory by Center, only the first center  displays well and the other one are in disorder like in the attached picture.
<apex:page controller="InventorySearchController2" action="{!load}" sidebar="false">
  <apex:sectionHeader title="FOOD FOR THE POOR INVENTORY" subtitle="Group by Distribution Center" 
    description="This page shows how you all the product in stock group by Center"/>

  <apex:repeat value="{!centers}" var="center">

    <apex:pageBlock title="{!center}">
	 
	   <apex:repeat value="{!inventoryItems}" var="inventoryItem"> 
             <apex:outputPanel rendered="{!IF(center=inventoryItem.FFP_Centers__c,true,false)}">
         
		 <tr> 
							 <th>Center</th> 
							 <th>Product</th> 
							 <th>Unit Of Measure </th> 
							 <th>Container</th> 
							 <th>Order Number</th> 
							 <th>On Hand</th>
							 <th>Pending</th> 
							 <th>Available</th> 
							 <th>Purpose</th> 
							 <th>Condition</th> 
							 <th>Age</th> 
							 <th>Comments</th>
                     </tr> 
                      <tr>     
					        <td>{!inventoryItem.FFP_Centers__c } </td/>                        
                            <td>{!inventoryItem.Prod__c}</td/>  
                            <td>{!inventoryItem.UM__c}</td/>  
                            <td>{!inventoryItem.Container__c}</td/>   
                            <td>{!inventoryItem.Number__c}</td/>   
                            <td>{!inventoryItem.On_Hand__c}</td/>  
                            <td>{!inventoryItem.Pending__c}</td/>  
                            <td>{!inventoryItem.Available__c}</td/>  
                            <td>{!inventoryItem.Purpose__c}</td/>  
                            <td>{!inventoryItem.Condition__c}</td/>  
                            <td>{!inventoryItem.Age__c}</td/>  
                            <td>{!inventoryItem.Comments__c}</td/>  
					  </tr>
        </apex:outputPanel>     
    </apex:repeat>  

    </apex:pageBlock>

  </apex:repeat>

</apex:page>


// Controller


public with sharing class InventorySearchController2 { 
public list <Articles_Containers__c> inventoryItems {get;set;} 
public String[] centers {get;set;}  

 public void load() {

inventoryItems =[Select  FFP_Centers__c , Prod__c, UM__c, Container__c, 
Number__c, On_Hand__c,  Pending__c,  Available__c, Purpose__c, Condition__c, 
Age__c, Comments__c FROM Articles_Containers__c  WHERE On_Hand__c >0  AND IsOpened__c = 1 
 ORDER BY FFP_Centers__c Limit 50000];
     
    
Set<String> centerSet = new Set<String>();
    for (Articles_Containers__c ac : inventoryItems)
      centerSet.add(ac.FFP_Centers__c); 
      
      centers = new String[centerSet.size()];
    Integer i = 0;
    for (String center : centerSet) { 
      centers[i] = center;
      i++;
    }
  }
}
User-added image
Help me with this please

https://developer.salesforce.com/forums/ForumsMain?id=9062I000000g9naQAA
I have a custom object callled Container__c with a child called Articles_Containers__r where Item_Distributed__c in his turn the the child of Articles_Containers__r.   I want to search / filter data and display the  visualforce page externally on my website based on information provided for the Container__r object. When the user goes one  the website page he should provide the Invoice__c , Name,  Bill_of_Lading__c,  and PO__c of  a Container__c to access the VF mached with the provided information.   Actually i am able to diplay the result on the VF page inside of saleforce trough a button on the page layout(picture attached).  Please let me know all the the steps i have to follow. 
My controller
public class ContainerTrackerController
{
    public Container__c container {get;set;}
    public Map<String,List<Item_Distributed__c>> itemDistributed{get;set;}
    String containerId;
    
    
          
    
     
    public ContainerTrackerController()
    {
        container = new Container__c();
        itemDistributed = new Map<String,List<Item_Distributed__c>>();
        
        try
        {
            containerId = ApexPages.currentPage().getParameters().get('id');
            
           container = [SELECT Id,Name,DR__c, PO__c,Arrived_Date__c, Invoice__c, Pkl__c, Description__c, Container__c.Provenance__c, Percent_Distributed__c, Bill_of_Lading__c, Size_in_feet__c, Seal_No__c, 
                         (SELECT Id,Name,Prod__c,Number__c,Number_Distributed__c,Available__c,UM__c, Pending__c, Percentagedistributed__c, Lot_Number__c FROM Articles_Containers__r)
                         FROM Container__c WHERE  Id =:containerId];

            if(container != null)
            {
                Set<Id> articleContainersId = new Set<Id>();
                
                if(!container.Articles_Containers__r.isEmpty())
                {
                    for(Articles_Containers__c art :container.Articles_Containers__r)
                    {
                        articleContainersId.add(art.Id);
                        itemDistributed.put(art.Id, new List<Item_Distributed__c>());
                    }
                }
                
                List<Item_Distributed__c> lstItemDistributed = new List<Item_Distributed__c>();
                
                lstItemDistributed = [SELECT Id, Name,Product__c,Quantity__c,Delivery__c,Productt__c, Beneficiary__c, Date__c , Delivery__r.Beneficiaire__r.Beneficiary_ID__c, Delivery__r.Beneficiaire__r.Class__c, Delivery__r.Beneficiaire__r.Departement__c, Delivery__r.Beneficiaire__r.Type, Delivery__r.Beneficiaire__r.New_ID__c 
                                      FROM Item_Distributed__c WHERE  Del_Status__c='Delivered'AND Product__c IN :articleContainersId];
                
                if(!lstItemDistributed.isEmpty())
                {
                    for(Item_Distributed__c item :lstItemDistributed)
                    {
                        if(itemDistributed.containsKey(item.Product__c))
                        {
                            itemDistributed.get(item.Product__c).add(item);
                        }
                    }
                }
            }         
        }
        catch(Exception e)
        {
            System.debug(e.getMessage());
        }
    }
}





the VF Page

<apex:page showHeader="false" sidebar="false"  standardStylesheets="false" Controller="ContainerReportController"  applyBodyTag="false" >
    
    <head>
        <style type="text/css" media="print">
        
       
            tr {
            //font-family: Consolas, monaco, monospace;
           // font-weight:6px;
            font-size:10px;}
            @page {    
            @bottom-left {
            content: element(footer);
            size:letter;
       
            }
            }
            // .tablebody{
            // font-size=18px;
            // }
            
            /*   .sectionHeader {
            width: 100%;
            //background-color: #eee;
            
            font-size: 20pt;
            padding: 0px;
            margin: 15px 0px;
            font-weight: bold;
            }*/
            .head{
            width:65%;
            display: table;
            }
            .col {
            display:table-cell;
            line-height:1.1em;
            vertical-align: middle;
            }
            
            .logo{
            width: 30%;
            
            }
            .name{
            width: 70%;
            }
            .name h2, .name h6{
            margin: 0;
            padding: 0;
            margin-left: 10px;
            
            line-height: 1.1em;
            }
            
            .tableHeader {
            border-width: 1px 0px 1px 0px;
            border-color: #000;
            border-style: solid;
            }
            h4, h3{Text-align: Center;
            }
            
            table {
            width: 100%;
            }
            .centered {
            text-align: center;
            }
            
            .right {
            text-align: right;
            }
            
            .firstBlock
            {
            width: 90%; 
            margin-left: 20px;
            }
            
            
            .beneInfo{
            border-width: 1px 1px 1px 1px;
            border-style: solid;
            margin: 20px;
            
            
            }
            .SubfirstBlock{
            display:table-cell;
            width:800px;
            line-height: 1.5em;
            }
            .tableBeneinfo{
            display:table-cell;
            width:800px;
            line-height: 1.2em;
            
            }
            
            .tableBeneinfo div{
            border-top: 1px solid black;
            display: inline;
            margin-right:5px;
            width: 100px;
            text-align:center;
            }
            .footer {
            display: block;
            padding: 5px;
            position: running(footer);
            margin-bottom: 20px
            
            }
            
            .signature
            {margin-top:30px
           
            }
            
            .subfooter {
            display: inline-block;
            }
            
            .status{
            width: 30%;
            background-color: #eee;
            font-size: 12pt;
            padding: 5px;
            margin: 20px 0px;
            font-weight: bold;
            }
            
            
            
            div.right {
            float: right;
            }
            
            .pagenumber:before {
            content: counter(page);
            }
            
            .pagecount:before {
            content: counter(pages);
            }
        </style>
    </head>
    <div class="head">        
        <div class="col logo">
            <apex:image url="{!$Resource.LogoFFP}" width="140" height="60"/>
        </div>
        <div class ="col name"> 
            <h2>
                FOOD FOR THE POOR
            </h2>           
            <h6>
                14, Mapou Rte. Nationale #1, Cap Haitien, Haiti <br/>
                Tels:(+509)2208-9960/3409-5328
            </h6>
        </div>        
    </div>
    
   <h3> {!Container.Name} : DETAILED DISTRIBUTION REPORT </h3>
    
   <div class="firstBlock" > 
        
        <div class ="SubfirstBlock">
                
            <div>
                <b>Description   :</b> {!Container.Description__c}
            </div>
            
            <div>
                 <b>Packing List Number  :</b>    {!Container.Pkl__c}

            </div>
            <div>
                <b>Invoice    :</b> {!Container.Invoice__c}

            </div>
            
            <div>
                 <b>PO   :</b>    {!Container.PO__c}

            </div>
             <div>
                <b>Seal :</b> {!Container.Seal_No__c}
            </div>
            
            
            
        </div>
        <div class ="SubfirstBlock">
            <div>
            
            
                <b>Arrival Date :</b> <apex:outputtext value="{0, date, long}">
        <apex:param value="{!Container.Arrived_Date__c}"></apex:param>
    </apex:outputtext>
            </div>
            
            <div>
                <b>Provenance    :</b> {!Container.Provenance__c}
            </div>
           
            
            <div>
                <b>Size in Feet   :</b> {!Container.Size_in_feet__c}
            </div>
            <div>
                <b>Bill Of Lading    :</b> {!Container.Bill_of_Lading__c}
            </div>
            
             <div>
                 <b>Overall Distribution :</b>    {!COntainer.Percent_Distributed__c} %

            </div>
            
        </div>
    </div>
     
  
  
    <h3> DISTRIBUTION DETAILS</h3>
   
      <table style="width:100%;border-collapse: collapse;">
      
     
      <tr>
                  <td> <b>CODE </b></td>
                  <td> <b>ITEM </b></td>
                  <td> <b>UoM </b></td>
                  <td> <b>#RECEIVED </b></td>
                  <td> <b>#DISTR. </b></td>
                  <td> <b>BALANCE</b></td>
                  <td> <b>#PENDING</b></td>
                  <td> <b>%DISTR.</b></td>
                  
              </tr>
          <apex:repeat value="{!container.Articles_Containers__r}" var="article">
          
          
          
              <tr>
                  <td style="background:#000080;color:white;"><b>{!article.Name}</b></td>
                  <td style="background:#000080;color:white;"><b>{!article.Prod__c}</b></td>
                  <td style="background:#000080;color:white;"><b>{!article.UM__c}</b></td>
                  <td style="background:#000080;color:white;"><b>{!article.Number__c}</b></td>
                  <td style="background:#000080;color:white;"><b>{!article.Number_Distributed__c}</b></td>
                  <td style="background:#000080;color:white;"><b>{!article.Available__c}</b></td>
                  <td style="background:#000080;color:white;"><b>{!article.Pending__c}</b></td>
                  <td style="background:#000080;color:white;"><b>{!article.Percentagedistributed__c} %</b></td>
                  
              </tr>
              
               <tr>
                   <td> <b> Deliv. Item Code </b></td>
                   <td> <b> Beneficiary</b></td>
                   <td> <b> #Given</b></td>
                   <td> <b> Date</b></td>
                   <td> <b> Del.Number</b></td>
              </tr>
              <apex:repeat value="{!itemDistributed[article.Id]}" var="item">
                  <tr>
                      <td>{!item.Name}</td>
                       <td>{!item.Beneficiary__c}</td>
                      <td>{!item.Quantity__c}</td>
                      
                     <td> <apex:outputtext value="{0, date, medium}">
                     <apex:param value="{!item.Date__c}"></apex:param>
                     </apex:outputtext> <br/></td>
                      
                      <td><apex:outputField value="{!item.Delivery__c}"/></td>
                  </tr>
              </apex:repeat>
          </apex:repeat>
      </table>
      
</apex:page>




 
the visualforce page with results i want access outside of salesforce
I want want to update child in a  self  lookup relationship with value of the parent. The idea is to create a child with projectType ='Sanitition' when a record is created with the type of House. And update the child anytime the parent is updated.  The error msg i get is: Illegal assignment from List<Output__c> to Map<Id,Output__c>  at the line 29
trigger AutoOutput on Output__c (after insert, after update) {
    
If(Trigger.isInsert){
List<Output__c> lstNewOutputs = new List<Output__c>();
for (Output__c NewOut : Trigger.New) {
if ( NewOut.Project_Type__c =='House') {
Output__c OutputChild = new Output__c();
OutputChild.Housing_If_Sanitation__c= NewOut.Id;
OutputChild.Project_Type__c = 'Sanitition';
OutputChild.RecordTypeId=NewOut.RecordTypeId;
OutputChild.Description__c=NewOut.Description__c;
OutputChild.Locality__c=NewOut.Locality__c;
OutputChild.Milestone__c= NewOut.Milestone__c;
OutputChild.Address__c = NewOut.Address__c;
OutputChild.claust__c=NewOut.claust__c;
OutputChild.A__c=NewOut.A__c;
OutputChild.Besem__c = NewOut.Besem__c;
lstNewOutputs.add(OutputChild);
}     
   
}
if(!lstNewOutputs.isEmpty())
INSERT lstNewOutputs;
}
If(Trigger.isUpdate){
    
Map<Id,Output__c> outputsWithChilds = new Map<Id,Output__c>();
List<Output__c> lstNewOutputs = new List<Output__c>();
outputsWithChilds = [SELECT Id,(SELECT Id FROM Housing_If_Sanitation__r WHERE Project_Type__c = 'Sanitition')FROM Output__c WHERE Id IN :Trigger.New];
for (Output__c NewOut : Trigger.New) {
if (NewOut.Project_Type__c =='House') {
Output__c OutputChild = new Output__c();
OutputChild.Housing_If_Sanitation__c= NewOut.Id;
OutputChild.Project_Type__c = 'Sanitition';
OutputChild.RecordTypeId=NewOut.RecordTypeId;
OutputChild.Description__c=NewOut.Description__c;
OutputChild.Locality__c=NewOut.Locality__c;
OutputChild.Milestone__c= NewOut.Milestone__c;
OutputChild.Address__c = NewOut.Address__c;
OutputChild.claust__c=NewOut.claust__c;
OutputChild.A__c=NewOut.A__c;
OutputChild.Besem__c = NewOut.Besem__c;
if(!outputsWithChilds.get(NewOut.Id).Housing_If_Sanitation__r.isEmpty()){
OutputChild.Id = outputsWithChilds.get(NewOut.Id).Housing_If_Sanitation__r[0].Id;
}
lstNewOutputs.add(OutputChild);
}
}
if(!lstNewOutputs.isEmpty())
UPSERT lstNewOutputs;
    }
}
I need to implement a validation rule which should take effect  for all new record created after a specific date. I have a field called  Unit_Cost__c , this field can not be blank for all records created after  July 25, 2019. Below is a draft of my work.  The error message is: Syntax error. Missing ')'

AND(DateValue(CreatedDate)=>Date(2019, 07,25 ), 
(ISBLANK(  Unit_Cost__c  )))
I need to search data in a visualforce with criteria from multiple field.
The field which will be used as Critieria are:
Purpose__c  : Picklist
Condition__c : Picklist
Prod__c : Text
UM__c: Picklist
Container__c: Text

the code below allow me to set criteria for one field. Help me to improve it.
public with sharing class InventorySearchController { 
public list <Articles_Containers__c> inventoryItem {get;set;} 
public string searchstring {get;set;} 
public InventorySearchController( ) { 
} 
public void search(){ 
string searchquery= 'select Name , Prod__c, UM__c, Container__c, Number__c, On_Hand__c,  Pending__c,  Available__c, Purpose__c, Condition__c, Age__c, Comments__c FROM Articles_Containers__c  WHERE Prod__c like \'%'+searchstring+'%\'  AND On_Hand__c >0  AND IsOpened__c = 1  Limit 50000';
     
      inventoryItem= Database.query(searchquery); 

}
public void clear(){ 
inventoryItem.clear(); 
} 
}

// VF
<apex:page Controller="InventorySearchController"  Sidebar="False"> 
<apex:form > 
<apex:inputText value="{!searchstring}" label="Input"/> 
<apex:commandButton value="Search records" action="{!search}"/> 
<apex:commandButton value="Clear records" action="{!clear}"/> 
<apex:pageBlock title="Search Result"> 
<apex:pageblockTable value="{!inventoryItem}" var="a"> 

<apex:column value="{!a.Name}"/> 
<apex:column value="{!a.Prod__c}"/> 
<apex:column value="{!a.UM__c}"/> 
<apex:column value="{!a.Container__c}"/> 
<apex:column value="{!a.Number__c}"/> 
<apex:column value="{!a.On_Hand__c}"/> 
<apex:column value="{!a.Pending__c}"/> 
<apex:column value="{!a.Available__c}"/> 
<apex:column value="{!a.Purpose__c}"/> 
<apex:column value="{!a.Condition__c}"/> 
<apex:column value="{!a.Age__c}"/> 
<apex:column value="{!a.Comments__c}"/> 
</apex:pageBlockTable> 
</apex:pageBlock> 
</apex:form> 
</apex:page>


 
Hi  All, I want group record by the  field named Shipment_Status__c  as attached.  I get the error "only aggregate expressions use field aliasing"
Here the controller
public class ContainerGlobalShipmentController{
public Map<String, List<Container__c>> Records { get; set; }
public ContainerGlobalShipmentController() {
 Records = new Map<String, List<Container__c>>();
 Container__c [] results =
[SELECT  Shipment_Status__c status, Pkl__c, PO__c, Invoice__c,Name, Size_in_feet__c, Description__c, 
Bill_of_Lading__c,On_Wharf_Date__c,Sailing__c,ETA__c,Demurrage_begins__c,
Brocker__c,Comments__c,     ID_Container__c,  Consignee__c, Provenance__c
 FROM Container__c WHERE (Departed_to_Wharf_Date__c = NULL OR 
 (Departed_to_Wharf_Date__c =LAST_N_DAYS:5))   
 AND Provenance__c ='FFP FLORIDA'];
 
  for(Container__c result: results) {
     status = (String)result.get('status');
    if(!Records.containsKey(status)) {
      Records.put(status, new Container__c[0]);
    }
    Records.get(status).add(result);
  }
}
}

User-added image
I want want to update child in a  self  lookup relationship with value of the parent. The idea is to create a child with projectType ='Sanitition' when a record is created with the type of House. And update the child anytime the parent is updated.  The error msg i get is: Illegal assignment from List<Output__c> to Map<Id,Output__c>  at the line 29
trigger AutoOutput on Output__c (after insert, after update) {
    
If(Trigger.isInsert){
List<Output__c> lstNewOutputs = new List<Output__c>();
for (Output__c NewOut : Trigger.New) {
if ( NewOut.Project_Type__c =='House') {
Output__c OutputChild = new Output__c();
OutputChild.Housing_If_Sanitation__c= NewOut.Id;
OutputChild.Project_Type__c = 'Sanitition';
OutputChild.RecordTypeId=NewOut.RecordTypeId;
OutputChild.Description__c=NewOut.Description__c;
OutputChild.Locality__c=NewOut.Locality__c;
OutputChild.Milestone__c= NewOut.Milestone__c;
OutputChild.Address__c = NewOut.Address__c;
OutputChild.claust__c=NewOut.claust__c;
OutputChild.A__c=NewOut.A__c;
OutputChild.Besem__c = NewOut.Besem__c;
lstNewOutputs.add(OutputChild);
}     
   
}
if(!lstNewOutputs.isEmpty())
INSERT lstNewOutputs;
}
If(Trigger.isUpdate){
    
Map<Id,Output__c> outputsWithChilds = new Map<Id,Output__c>();
List<Output__c> lstNewOutputs = new List<Output__c>();
outputsWithChilds = [SELECT Id,(SELECT Id FROM Housing_If_Sanitation__r WHERE Project_Type__c = 'Sanitition')FROM Output__c WHERE Id IN :Trigger.New];
for (Output__c NewOut : Trigger.New) {
if (NewOut.Project_Type__c =='House') {
Output__c OutputChild = new Output__c();
OutputChild.Housing_If_Sanitation__c= NewOut.Id;
OutputChild.Project_Type__c = 'Sanitition';
OutputChild.RecordTypeId=NewOut.RecordTypeId;
OutputChild.Description__c=NewOut.Description__c;
OutputChild.Locality__c=NewOut.Locality__c;
OutputChild.Milestone__c= NewOut.Milestone__c;
OutputChild.Address__c = NewOut.Address__c;
OutputChild.claust__c=NewOut.claust__c;
OutputChild.A__c=NewOut.A__c;
OutputChild.Besem__c = NewOut.Besem__c;
if(!outputsWithChilds.get(NewOut.Id).Housing_If_Sanitation__r.isEmpty()){
OutputChild.Id = outputsWithChilds.get(NewOut.Id).Housing_If_Sanitation__r[0].Id;
}
lstNewOutputs.add(OutputChild);
}
}
if(!lstNewOutputs.isEmpty())
UPSERT lstNewOutputs;
    }
}
Where do you thank the problem is. the trigger is save but does not fire.  The idee is to create a child record on a self relationship when outputType is House. Help me please
trigger AutoOutput on 	Output__c (after insert, after update) {
    List<Output__c> Output = new List<Output__c>();

     
    for (Output__c NewOut : Trigger.New) {
        if ( NewOut.OutputType__c =='House') {
            Output__c OutputChild = new Output__c();
            OutputChild.Housing_If_Sanitation__c= NewOut.Id;
            OutputChild.Project_Type__c = 'Sanitition';
            OutputChild.RecordTypeId='Infrastructure';
            OutputChild.Description__c='Discrption';
            OutputChild.Locality__c='ghjggh';
            Output.add(OutputChild);
        }
    }
    upsert Output;
}