• Morino Italis 8
  • NEWBIE
  • 10 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
I have trigger which send an attchement to a recipient email when  a field called Percent_distributed__c of an object called Container__c is 100%.  It worked fine.  A new field called Center__c was added to the same object and my new requirement is 
-  send the email to a recipient email A, if the Center is X, 
-  send the email to a recipient email B, if the Center is Y, 
-  send the email to a recipient email C, if the Center is Z, 

in the code below, i get an error saying  : 
 Compile Error: Extra ';', at '}'. at line 89 column 85

Here is my Code
public class DetailedDistributionTrigger
{
    public static void afterUpdateOperation(List<Container__c> lstNewContainers, Map<Id, Container__c> mapOldContainers)
    {
        List<String> lstUpdatedContainerIds = new List<String>();
       
        for(Container__c newContainer : lstNewContainers)
        {
            Container__c oldContainer = new Container__c();
           
            oldContainer = mapOldContainers.get(newContainer.Id);
           
            if(!Test.isRunningTest())
            {
                if(newContainer.Percent_Distributed__c == 100 && oldContainer.Percent_Distributed__c != 100)
                {
                    lstUpdatedContainerIds.add(newContainer.Id);
                }
            }
            else
                lstUpdatedContainerIds.add(newContainer.Id);
        }
       
        if(!lstUpdatedContainerIds.isEmpty())
            sendContainerPDF(String.join(lstUpdatedContainerIds,','));
    }
   
    @future(callout = true)
    public static void sendContainerPDF(String strUpdatedContainers)
    {
        List<String> lstContainerIds = new List<String>();
        lstContainerIds = strUpdatedContainers.split(',');
       
        List<Container__c> lstContainers = new List<Container__c>();
        
        if(!lstContainerIds.isEmpty())
        {
            lstContainers = [SELECT Id,Name, Owner.Email FROM Container__c WHERE Id IN :lstContainerIds];
        }
       
        for(Container__c Container :lstContainers)
        {
           // if(Container.Requisitor__c != null && Container.Requisitor__r.Contact_email__c != null)
           // {
            //    sendpdfEmail(Container,Container.Requisitor__r.Contact_email__c);
          //  }
           
          if(Container.Owner.Email != null)
           {
              sendpdfEmail(Container, Container.Owner.Email);
           }
        } 
    }
   
    public static void sendpdfEmail(Container__c Container, String emailid)
    {
        // Define the email
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
 
        // Reference the attachment page and pass in the account ID
        PageReference pdf =  Page.ContainerDetailedDistributionExcel;
        pdf.getParameters().put('id',Container.Id);
        pdf.setRedirect(true);
        Blob pdfData;
       
        // Take the PDF content
        if(!Test.isRunningTest())
        {
            pdfData = pdf.getContent();
        }
        else
        {
            pdfData = Blob.valueOf('test');
        }
        // Create the email attachment
        Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
        efa.setFileName(Container.Name + '.xls');
        efa.setBody(pdfData);
 
        //String[] toAddresses = new List<String> {emailId};
        //email addresses to send email
            String[] toAddresses = new List<String>{'capcontainerdistribrep@foodforthepoorhaiti.org'};
            String[] toCanteenAddresses = new List<String>{'crndistributionreport@foodforthepoorhaiti.org'};
            String[] toCrnAddresses = new List<String>{'bcldistributionreport@foodforthepoorhaiti.org'};
 
        // Sets the paramaters of the email
       
        email.setSubject(Container.Name +' Detailed Distribution Report');
//Line 85

        if(COntainer.FFP_Center__c =='FFP Nord'){
           email.setToAddresses( toAddresses )
        };
        email.setPlainTextBody('The Container ' + Container.Name +  ' has been totally distributed, Please find attached the detailed distribution report' );
 
        email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});
 
        // Sends the email
        Messaging.SendEmailResult [] r =
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
    }
}


 
I need to display in a visualforce page the child date related to a parent based on some criteria on the child. In other terms i want 
 to have All the Container__c with status__c 'New' related to Account through a button placed in the layout page of Account.   
 I dot not find any error message but the criteria is not take effect as it is in the clause WHERE in the SOQL.

Here is my Extention Controller:
public with sharing class ContainerShipmentControllerExtension{

    public ContainerShipmentControllerExtension(ApexPages.StandardController controller) {

    }

public List<Container__c> Records {get; set;}
public ContainerShipmentControllerExtension(){
Records =
[select Pkl__c, Invoice__c, Size_in_feet__c, Description__c, 
Bill_of_Lading__c, Demurrage_begins__c, Brocker__c
 FROM Container__c WHERE Statut__c ='New'];
}
}

// my Visualforce page is:
<apex:page renderAs="pdf" showHeader="false" sidebar="false"  applyBodyTag="false" standardStylesheets="True" standardController="Account" extensions="ContainerShipmentControllerExtension"> 

<head>
        <style type="text/css" media="print">
        
        @page {
                size: landscape;
            }
            
            
            .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 - {!Account.Name}
            </h2>           
            <h6>
                14, Mapou Rte. Nationale #1, Cap Haitien, Haiti <br/>
                Tels:(+509)2208-9960/3409-5328
            </h6>
        </div>        
    </div>
    
    <h3>Shipment Update </h3>
    

 
 <br/> <br/>
 <table width="100%"> 
 <tr> 
 <th>Ref#</th> 
 <th>Lead/PO</th>
 <th>Invoice#</th> 
 <th>Size</th>
 <th>Shipper</th> 
 <th>Description</th> 
 <th>Bill of Lading No</th>
 <th>On Wharf</th> 
 <th>Inv Florida</th> 
 <th>Sailing</th> 
 <th>ETA</th>
 <th>Demurrage</th> 
 <th>Broker</th> 
 <th>Comment</th>
 <th>Consignee</th> 
 </tr> 
 <apex:repeat var="c" value="{!Account.Containers__r}"> 
 <tr>
 <td>{!c.Pkl__c}</td>
 <td>{!c.PO__c}</td>
 <td>{!c.Invoice__c}</td>
 <td>{!c.Size_in_feet__c}</td>
 <td>{!c.Description__c}</td>
 <td>{!c.Bill_of_Lading__c}</td>
 <td>{!c.Demurrage_begins__c}</td>  
 <td>{!c.Brocker__c}</td>
 <td>{!c.Comments__c} </td>
 <td>{!c.Consignee__c}</td>
 <td>{!c.Demurrage_begins__c}</td>  
 <td>{!c.Brocker__c}</td>
 <td>{!c.Comments__c}</td>
 <td>{!c.Consignee__c}</td> 
  </tr>
 </apex:repeat>
 </table> 
 
  <div class="footer">
        <div>       
            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>
    </div>     
</apex:page>

 
I need to display in a visualforce page the child date related to a parent based on some criteria on the child. In other terms i want 
 to have All the Container__c with status__c 'New' related to Account through a button placed in the layout page of Account.   
 I dot not find any error message but the criteria is not take effect as it is in the clause WHERE in the SOQL.

Here is my Extention Controller:
public with sharing class ContainerShipmentControllerExtension{

    public ContainerShipmentControllerExtension(ApexPages.StandardController controller) {

    }

public List<Container__c> Records {get; set;}
public ContainerShipmentControllerExtension(){
Records =
[select Pkl__c, Invoice__c, Size_in_feet__c, Description__c, 
Bill_of_Lading__c, Demurrage_begins__c, Brocker__c
 FROM Container__c WHERE Statut__c ='New'];
}
}

// my Visualforce page is:
<apex:page renderAs="pdf" showHeader="false" sidebar="false"  applyBodyTag="false" standardStylesheets="True" standardController="Account" extensions="ContainerShipmentControllerExtension"> 

<head>
        <style type="text/css" media="print">
        
        @page {
                size: landscape;
            }
            
            
            .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 - {!Account.Name}
            </h2>           
            <h6>
                14, Mapou Rte. Nationale #1, Cap Haitien, Haiti <br/>
                Tels:(+509)2208-9960/3409-5328
            </h6>
        </div>        
    </div>
    
    <h3>Shipment Update </h3>
    

 
 <br/> <br/>
 <table width="100%"> 
 <tr> 
 <th>Ref#</th> 
 <th>Lead/PO</th>
 <th>Invoice#</th> 
 <th>Size</th>
 <th>Shipper</th> 
 <th>Description</th> 
 <th>Bill of Lading No</th>
 <th>On Wharf</th> 
 <th>Inv Florida</th> 
 <th>Sailing</th> 
 <th>ETA</th>
 <th>Demurrage</th> 
 <th>Broker</th> 
 <th>Comment</th>
 <th>Consignee</th> 
 </tr> 
 <apex:repeat var="c" value="{!Account.Containers__r}"> 
 <tr>
 <td>{!c.Pkl__c}</td>
 <td>{!c.PO__c}</td>
 <td>{!c.Invoice__c}</td>
 <td>{!c.Size_in_feet__c}</td>
 <td>{!c.Description__c}</td>
 <td>{!c.Bill_of_Lading__c}</td>
 <td>{!c.Demurrage_begins__c}</td>  
 <td>{!c.Brocker__c}</td>
 <td>{!c.Comments__c} </td>
 <td>{!c.Consignee__c}</td>
 <td>{!c.Demurrage_begins__c}</td>  
 <td>{!c.Brocker__c}</td>
 <td>{!c.Comments__c}</td>
 <td>{!c.Consignee__c}</td> 
  </tr>
 </apex:repeat>
 </table> 
 
  <div class="footer">
        <div>       
            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>
    </div>     
</apex:page>