• nasir jawed
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 3
    Replies

Hi All,

 

I have written a Email controller,which is attached to a vf page.There is an ORDER object which has contact__c field as a lookup.An another object called Job__c,which is a related list to the Order__c object and has a field called job_Flag__c ,When ever the job_Flag__c field is true ,an email is send to the contact email field which is in the Order object.

What i want is ,when i send an email and the user opens the email he should see the entire VF page in the body of the email.

 

I am using setInline(true) in the attachment method.But i cannot find any changed in the email.It is still coming as an attachment.

 

The code i had attached below and the VF page also.

<apex:page standardController="Order__c"  showHeader="false" extensions="PopulateOrderValues" renderAs="pdf" >
<html>
    <head>
        <title>Order Received</title>
    </head>
    <body>
    <table width="600" border="0" cellpadding="0" cellspacing="0">
        <tr>
            <td><img src="https://c.cs5.content.force.com/servlet/servlet.ImageServer?id=015O00000008wm7&oid=00DO0000000CqOz&lastMod=1320735422000"/></td>
        </tr>
        <tr>        
            <td height="70" align="center" valign="top"><font color="#646464" size="5" face="Helvetica, Arial, sans-serif"><Center>THANK YOU FOR YOUR ORDER!</center></font><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">We will send you a notification once your order is ready for shipment.</font></td>
        </tr>
        <tr>
            <td height="30" align="center" valign="top"><img src="" width="600" height="1"/></td>
        </tr>
        <tr>
            <td>
            <table width="600" border="0" cellpadding="0" cellspacing="0">
                <tr>                
                    <td width="25">&nbsp;</td>
                    <td width="550" height="30" valign="top"><font face="Helvetica, Arial, sans-serif" color="#646464" size="3" style="font-size:19px">ORDER INFORMATION</font></td>
                    <td width="25">&nbsp;</td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                <td>
                    <table width="550" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                        
                            <td width="95"><strong><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">Order number</font></strong></td>
                            <td width="180"><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">{!Order__c.Order_ID__c}</font></td>
                            <td width="95" rowspan="5" valign="top"><strong><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">Deliver to</font></strong></td>
                            <td width="180" rowspan="5" valign="top"><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">{!currentOrder.Account__r.PersonMailingStreet}, {!currentOrder.Account__r.PersonMailingCity},
                            {!currentOrder.Account__r.PersonMailingState},{!currentOrder.Account__r.PersonMailingPostalCode},{!currentOrder.Account__r.PersonMailingCountry}, </font></td>
                        </tr>
                        <tr>
                            <td><strong><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">Cost centre</font></strong></td>
                            <td><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">{!Order__c.Cost_Center__c}</font></td>
                        </tr>
                        
                        <tr>        
                            <td><strong><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">Employee</font></strong></td>
                            <td><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">{!currentOrder.Contact__r.Name}</font></td>
                        </tr>
                        <tr>
                            <td><strong><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">Phone</font></strong></td>
                            <td><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">{!currentOrder.Account__r.Phone}</font></td>
                        </tr>
                        
                        <tr>
                            <td><strong><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">Email</font></strong></td>
                            <td><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">{!Order__c.Contact_Email__c}</font></td>
                        </tr>
                    </table>
                </td>
            <td>&nbsp;</td>
            </tr>     
            <tr>
                <td>&nbsp;</td>
                <td height="20">&nbsp;</td>
                <td>&nbsp;</td>
            </tr>
      
            <style type="text/css">        
                .odd {
                    background-color: #fae1c3;
                }
                .even {
                    background-color: #f2f2e8;
                }
                
                .Lastcolour{
                    background-color: #E3E3D9;
                }
                
                .h { width:1000px;
                   height:150px;
                }
                 
                .pr { width:900px;
                height:100px;}          
            </style>
           
            <apex:form > 
            <apex:pageBlock >
                <apex:dataTable value="{!job}" var="j" style="Helvetica, Arial, sans-serif;valign='right'" rowClasses="odd,even"  >
                           
                    <apex:column styleClass="h" >
                        <apex:facet name="header" ><td valign="top" width="10%"><b>Item#</b></td></apex:facet>
                        <td valign="top" width="10%"><apex:outputText value="{!j.Job_ID__c}" styleClass="mystyle" /></td>
                    </apex:column> 
                    
                    <apex:column styleClass="h"  >
                        <apex:facet name="header"><td valign="top" width="10%"><b>Date</b></td></apex:facet>
                        <td valign="top"><apex:outputField value="{!Order__c.Order_Date__c}"  styleClass="mystyle"/></td>
                    </apex:column>
                    
                    <apex:column styleClass="h">
                        <apex:facet name="header"><td valign="top" width="10%"><b>Quantity</b></td></apex:facet>
                        <td valign="top"><apex:outputText value="{!j.Quantity__c}"  styleClass="mystyle"/></td>
                    </apex:column>
                    
                    <apex:column styleClass="pr" >
                        <apex:facet name="header">Product</apex:facet> 
                        <table border="0" >
                            <tr>
                                <td valign="top" ><b><i>EMC Business Card Front</i></b> &nbsp; {!j.Front_Template_Name__c}</td>
                            </tr>
                            
                            <tr>
                                <td valign="top"><b>Delivery</b> &nbsp; {!j.Front_Template_Name__c}</td>
                            </tr>
                            
                            <tr>
                                <td valign="top"><b>Base</b> &nbsp; {!j.Material_Type__c}</td>
                            </tr>
                            
                            <tr>
                                <td valign="top"><b>Lamination</b> &nbsp; {!j.Lamination__c}</td>
                            </tr>
                            
                            <tr>
                                <td valign="top"><b>Printed Sides</b>&nbsp; {!j.Printing_Side__c}</td>
                            </tr>
                            
                            <tr>
                                <td valign="top"><b>Dimensions</b>&nbsp; {!j.Dimension__c}</td>
                            </tr>
                            
                            <tr>
                                <td valign="top" ><b>Delivery Zone</b> &nbsp;{!j.Delivery_State__c}</td>
                            </tr>
                            </table> 
                    
                    </apex:column> 
                                
                                                   
                    
                    <apex:column styleClass="h" >
                        <apex:facet name="header"><td valign="top" width="10%"><b>Cost</b></td></apex:facet>
                        <td valign="top" width="10%"><apex:outputText value="{!j.Item_Price__c}"  styleClass="mystyle"/></td>
                    </apex:column>
                            
                </apex:dataTable>
            </apex:pageBlock> 
            </apex:form> 
   
    
            <table  ALIGN="right" face="Helvetica, Arial, sans-serif" size="2" style="font-size:12px">
                <tr>
                    <td style="font-size:15px" width="45%" ALIGN="left"><Strong>Cost Of Items</Strong></td>
                    <td width="17%" style="font-size:15px"><apex:outputText value="{!Order__c.Cost_of_Items__c}"/></td>
                </tr> 
                <tr>  
                    <td style="font-size:15px"  width="45%" ALIGN="left"><Strong><apex:outputText value="Delivery"/></Strong></td>
                    <td width="17%" style="font-size:15px"> <apex:outputText value="{!Order__c.Freight_Cost__c}"/></td>
                </tr>    
                <tr>
                   <td style="font-size:15px" width="45%" ALIGN="left"> <Strong><apex:outputText value="Total"/></Strong></td>
                    <td width="17%" style="font-size:15px"> <Strong><apex:outputText value="{!Order__c.Total_Charges__c}"/></Strong></td>
                 </tr>
            </table>   
                      
               
        </table>
            </td>
            </tr> 
            
            
                  
                    
            <table width="47%">
                <tr>
                    <td Align="Center" style="background-color:#E3E3D9;font-size:26px;" ><p><br>Best regards,</br>The EfficientLive Team</p></td>
                </tr>
            </table>
                    
        </table>           
    </body>
</html>
            
</apex:page>

 

public  class OrderEmail {

    public OrderEmail() {

    }

    public String subject;
    public String body='Please click the link';  
    public string jobId;
    
    public OrderEmail(ApexPages.StandardController controller) {
        jobId=ApexPages.currentPage().getParameters().get('jobId');
    }
      
    public void sendEmail(){   
        jobId=ApexPages.currentPage().getParameters().get('jobId');      
           
        Job__c tempJob = [Select Order__r.Account__c, Order__r.Account__r.IsPersonAccount, 
            Order__c, Order__r.Contact__c, Order__r.Contact__r.Email, Job_Flag__c, 
            Order__r.Account__r.PersonEmail
            from Job__c 
            
            where id=:jobId
            ];
        
            
        If(tempJob.Job_Flag__c== true){  
                
            Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();  
                
            PageReference p = Page.edm_orderreceived;
            p.getParameters().put('id',tempJob.Order__c);
            p.setRedirect(true);                
            // Take the PDF content
            Blob b = p.getContent();
               
            // Create the email attachment
            Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
            efa.setFileName('Order.pdf');
            efa.setBody(b);
          
            efa.setInline(true);
            system.debug('Attachment:'+ efa);
            
            if(tempJob.Order__r.Account__r.IsPersonAccount){
                email.setToAddresses (new String[] {tempJob.Order__r.Account__r.PersonEmail});                  
            }else{
                email.setToAddresses (new String[] {tempJob.Order__r.Contact__r.Email});
            }
            
            email.setSubject( subject );
            email.setPlainTextBody(body );          
                
            email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});

            Messaging.sendEmail(new Messaging.Email[] {email});                
      
        }
    }
    

}

 

Hi All,

 

I have written an apex controller and created a visual force page and i had used datatable for this.The master object is Order__c and child is Job__c. Suppose if there are 5 jobs related to an Order.I display this in visual force page by using dataTable.

 

I am not able to get alternate colours for all the 5 jobs.For example if there is 5 jobs and i user green and blue colour for even and odd.Then jobs in data table should display as blue,green ,blue,green,

 

Here is the Visual force page which i had used.

<apex:page standardController="Order__c"  showHeader="false" extensions="PopulateOrderValues" >
  <html>
<head>
<title>Order Received</title>
</head>
<style type="text/css">
c1 { color: #fae1c3; }
c2 { color: #FF0000; }
</style>


<body>


<table width="600" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td><img src="https://c.cs5.content.force.com/servlet/servlet.ImageServer?id=015O00000008wm7&oid=00DO0000000CqOz&lastMod=1320735422000"/></td>
  </tr>
  <tr>

    <td height="70" align="center" valign="top"><font color="#646464" size="5" face="Helvetica, Arial, sans-serif"><Center>THANK YOU FOR YOUR ORDER!</center></font><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">We will send you a notification once your order is ready for shipment.</font></td>
  </tr>
  <tr>
    <td height="30" align="center" valign="top"><img src="" width="600" height="1"/></td>
  </tr>
  <tr>
    <td><table width="600" border="0" cellpadding="0" cellspacing="0">
      <tr>

        <td width="25">&nbsp;</td>
        <td width="550" height="30" valign="top"><font face="Helvetica, Arial, sans-serif" color="#646464" size="3" style="font-size:19px">ORDER INFORMATION</font></td>
        <td width="25">&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><table width="550" border="0" cellspacing="0" cellpadding="0">
          <tr>

            <td width="95"><strong><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">Order number</font></strong></td>
            <td width="180"><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">{!Order__c.Order_ID__c}</font></td>
            <td width="95" rowspan="5" valign="top"><strong><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">Deliver to</font></strong></td>
            <td width="180" rowspan="5" valign="top"><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">{!currentOrder.Account__r.PersonMailingStreet}, {!currentOrder.Account__r.PersonMailingCity},
             {!currentOrder.Account__r.PersonMailingState},{!currentOrder.Account__r.PersonMailingPostalCode},{!currentOrder.Account__r.PersonMailingCountry}, </font></td>
          </tr>
          <tr>
            <td><strong><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">Cost centre</font></strong></td>
            <td><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">{!Order__c.Cost_Center__c}</font></td>
            </tr>
          <tr>

            <td><strong><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">Employee</font></strong></td>
            <td><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">{!currentOrder.Contact__r.Name}</font></td>
            </tr>
          <tr>
            <td><strong><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">Phone</font></strong></td>
            <td><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">{!currentOrder.Account__r.Phone}</font></td>
            </tr>

          <tr>
            <td><strong><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">Email</font></strong></td>
            <td><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">{!Order__c.Contact_Email__c}</font></td>
            </tr>
        </table></td>
        <td>&nbsp;</td>
      </tr>     
     <tr>
        <td>&nbsp;</td>
        <td height="20">&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      nasir
     <style type="text/css">

     .h { width:1000px;
      height:200px;}
      
      </style>

    <apex:form >
    <apex:pageBlock >
    <apex:dataTable value="{!job}" var="j" columns="5"  style="Helvetica, Arial, sans-serif" bgcolor="#fae1c3"  >
    
    <apex:column styleClass="h"  >
                <apex:facet name="header" >Item #</apex:facet>
                <p><apex:outputText value="{!j.Job_ID__c}" styleClass="mystyle"/></p>
    </apex:column>
    <apex:column styleClass="h" >
                <apex:facet name="header">Date</apex:facet>
                <apex:outputField value="{!Order__c.Order_Date__c}"  styleClass="mystyle"/>
    </apex:column>
    <apex:column styleClass="h">
                <apex:facet name="header">Quantity</apex:facet>
                <apex:outputText value="{!j.Quantity__c}"  styleClass="mystyle"/>
    </apex:column>
    <apex:column styleClass="h" >
                <apex:facet name="header">Product</apex:facet>
                
                <Strong><apex:outputText value="EMC Business Card Front"/></Strong>                
                <apex:outputField value="{!j.Front_Template_Name__c}"  styleClass="mystyle"/> 
                
                <Strong><apex:outputText value="Delivery"/></Strong>                
                <apex:outputField value="{!j.Delivery_Country__c}"  styleClass="mystyle"/>
                
                 <Strong><apex:outputText value="Base"/></Strong>                 
                <apex:outputField value="{!j.Material_Type__c}"/>
                
                 <Strong><apex:outputText value="Lamination"/></Strong>                 
                <apex:outputField value="{!j.Lamination__c}"/>
                
                 <Strong><apex:outputText value="Printed Sides"/></Strong>                
                <apex:outputField value="{!j.Printing_Side__c}"/>
                
                 <Strong><apex:outputText value="Dimendions"/></Strong>            
                <apex:outputField value="{!j.Dimension__c}"/>
                
                <Strong><apex:outputText value="Delivery Zone"/></Strong>                
                <apex:outputField value="{!j.Delivery_State__c}"/>
                
                
    </apex:column>
 
    
    <apex:column styleClass="h" >
              <apex:facet name="header">Cost</apex:facet>
              <apex:outputText value="{!j.Item_Price__c}"  styleClass="mystyle"/>
    </apex:column>
   
   </apex:dataTable>
    </apex:pageBlock> 
    </apex:form>  
    
   
   

<table  ALIGN="right" face="Helvetica, Arial, sans-serif" size="2" style="font-size:12px">
<tr>
    <td style="font-size:15px"><Strong><h1>Cost Of Items</h1></Strong></td>
    <td ALIGN="right"><apex:outputText value="{!Order__c.Cost_of_Items__c}"/></td>
</tr> 
<tr>  
    <td style="font-size:15px"><Strong><apex:outputText value="Delivery"/></Strong></td>
    <td ALIGN="right"> <apex:outputText value="{!Order__c.Freight_Cost__c}"/></td>
</tr>    
<tr>
   <td style="font-size:15px"> <Strong><apex:outputText value="Total"/></Strong></td>
    <td ALIGN="right" > <apex:outputText value="{!Order__c.Total_Charges__c}"/></td>
 </tr>
</table>   
      
   
    </table></td>
  </tr> 
  <tr>
    <td height="20">&nbsp;</td>
  </tr>
  <tr>
    <td><img src="" width="600" height="1" style="display:block"/></td>
  </tr>

  <tr>
    <td height="120" ALIGN="center" valign="middle" bgcolor="#E3E3D9"><font face="Helvetica, Arial, sans-serif" color="#646464" size="3" style="font-size:19px">Best regards,The EfficientLive Team</font></td>
  </tr>
</table>


</body>
</html>

</apex:page>

 and controller is 

public  class PopulateOrderValues {
    public Order__c order;
    public Order__c currentOrder{get;set;}
    public List<Job__c> job{get; set;}

    public PopulateOrderValues(ApexPages.StandardController controller) {
        order=(Order__c)controller.getRecord();
        currentOrder=[Select Contact__r.Email,Contact__r.Name,Account__r.Phone,Account__r.PersonMailingCity,Account__r.PersonMailingCountry,
        Account__r.PersonMailingPostalCode,
        Account__r.PersonMailingState,Account__r.PersonMailingStreet from Order__c where id=:Order.id];
        
        job=[Select  id,Job_ID__c,Order_Date__c,Quantity__c,Item_Price__c,Front_Template_Name__c,Delivery_Country__c
        ,Material_Type__c,Lamination__c,Printing_Side__c,Dimension__c,Delivery_State__c from Job__c where Order__c=:order.id ];
        System.debug('Nasir:'+ job);
    }

 Please let me know how can i change the colour for the records.

 

Thanks

Hi

 

I have created a formula field using CASE and in that i am diaplaying image in a custom object called QUOTA.I can see the Image.But i the customer want to see the image in a VF page.

 

My formula field is called MonDr and its formula is 

 

MonDr =IF(Monday_Achievement__c < Monday_Quota__c , "Black",IF(Monday_Achievement__c > Monday_Quota__c,"Red",IF(Monday_Achievement__c == Monday_Quota__c,"Yellow",null)))

 

and i am displaying this image by using CASE

 

MonDrImage(text)=IMAGE(CASE( MonDr__c , "Black"," /servlet/servlet.ImageServer?id=015O00000004oBU&oid=00DO00000005GiK&lastMod=1315504942000","Yellow","/servlet/servlet.ImageServer?id=015O00000004oBe&oid=00DO00000005GiK&lastMod=1315504988000","Red","https://c.cs5.content.force.com/servlet/servlet.ImageServer?id=015O00000004oBZ&oid=00DO00000005GiK&lastMod=1315504968000",""),"",30,30)

 

As i can see the image in page layout when the following condition are meet.

 

How can i dispay the same image in VF page????

 

As i had created the VF page and controller for this

<apex:page showHeader="false" controller="DataRepresentation" extensions="DataRepresentation">
    <center>
    <u>    
    <h1>My Data Representation</h1>
    </u>
    <br></br>
    
   
    <apex:pageBlock >
    <apex:pageBlockTable value="{!display}" var="dis">
     <apex:outputLabel >Monday:</apex:outputLabel>  
    <apex:outputText value="{!dis.MonDrImage__c}" escape="false"/>
    </apex:pageBlockTable>    
    </apex:pageBlock>
    
    </center>
</apex:page>

 The apex class is :

public class DataRepresentation {

  public Quotas__c q{get; set;}
  public String s;
  
  public Quotas__c getdisplay(){
        
        Id usrId = UserInfo.getUserId();
        Goals__c g =[Select id from Goals__c where User__c=:usrId];
        if(q!=null){
            q =[select MonDrImage__c,Monday_Quota__c from Quotas__c where 
                Week_of__c =: System.Today().toStartofWeek()
                and RecordTypeId=:Utility.getRecordTypeId('Daily')
                and Quota_For__c='Leads CY'
                and Goal__c=:g.Id limit 1
               ]; 
            }
             //System.debug('image:'+ q.Monday_Quota__c); 
        
        
              return q;
    }
   
   


}

 

:Please help me how can i display that formula field in VF page for Monday Quota

 

Thanks

 

Nasir

Hi 

 

I want to write the test method for this Class and i am not able to cover the SOQL statements.The line marked in red are not covered and the test coverage is 42%.How to cover SOQL statements.The with "Underline" are uncovered.Please help

 

 
public class ProjectCreation {
    public Opportunity oppn;
    public String sel {get; set;}
    public Account accRecord;
    private ID Id;
    public Boolean isConverted {get; set;}
    
    public ProjectCreation(ApexPages.StandardController controller) {
        oppn = (Opportunity)controller.getRecord();
        Opportunity op = [Select id,Convert_to_Project__c from Opportunity where id=:oppn.id];
        id = op.id;
        if(op.Convert_to_Project__c)
            isConverted = true;
        else
            isConverted = false;
    }
            
    public List<SelectOption> getassociated(){
        List<SelectOption> opts = new List<SelectOption>();
        opts.add(new SelectOption('New Project','New Project'));
        opts.add(new SelectOption('Existing Project','Existing Project'));
        return opts;
    }
    
    public PageReference saveProject(){         
        PageReference oppPage; 

         if(sel=='New Project'){
            oppn = [select id,name,CloseDate,Project_name__c,Convert_to_Project__c,Counter_Party_Supplier__c,AccountId,Amount,Description from Opportunity where id=:oppn.Id];
            accRecord = [Select Id,Business_Line__c,Industry_Cluster__c,Product_Category__c,Subindustry_cluster__c,Application__c from Account where Id = :oppn.AccountId];
            
            Project__c newProj = new Project__c(Name=oppn.Name, 
                Dateline__c=oppn.CloseDate, Kickoff__c=System.Today(), Account_Name__c=oppn.AccountId,
                Supplier_Name__c= oppn.Counter_Party_Supplier__c, Revenue_Expected_Year1__c=oppn.Amount,
                Description__c = oppn.Description,Project_Progress__c='10%',Status__c='Active' );
            newProj.Related_To_Opportunity__c = oppn.Id;
            newProj.Business_Line__c = accRecord.Business_Line__c;
            newProj.Industry_Cluster__c = accRecord.Industry_Cluster__c;
            newProj.Product_Category__c = accRecord.Product_Category__c;
            newProj.Sub_Industry_Cluster__c = accRecord.Subindustry_cluster__c;
            newProj.Application__c = accRecord.Application__c;
            insert newProj;

            List<Opportunity_Product__c> OP = [Select Id,Product__c,Quantity__c,Sales_Price__c,Margin_1__c,CurrencyIsoCode,UOM__c from Opportunity_Product__c where Opportunity_Name__c =:oppn.Id];
            
            //System.Debug(' Start OP Size ' + OP.size());
            if(OP != null){
                for(Opportunity_Product__c opr : OP){
                    
                    Project_Product__c newPP = new Project_Product__c(Project__c=newProj.id,Product__c=opr.Product__c,
                        Quantity__c=opr.Quantity__c,Sales_Price__c=opr.Sales_Price__c,Margin__c=opr.Margin_1__c,
                        CurrencyIsoCode=opr.CurrencyIsoCode,UOM__c=opr.UOM__c);
                    insert newPP;
                    //System.Debug(' LPPP ' + newPP.id);
                }
            }
            //System.Debug(' End ' + OP.size());   
            oppn.Convert_to_Project__c = true;
            oppn.Project_Name__c = newProj.id;
            update oppn;
            oppPage = new ApexPages.StandardController(newProj).view();
            oppPage.setRedirect(true);
            return oppPage; 
        }else if(sel=='Existing Project' ){
            if(oppn.Project_name__c!=null){
            
                Project__c existingProj= [Select id, Name from Project__c where  id =:oppn.Project_name__c];    
                existingProj.Related_To_Opportunity__c = oppn.Id;
                
                update existingProj;
                List<Opportunity_Product__c> OP = [Select Id,Product__c,Quantity__c,Sales_Price__c,Margin_1__c,CurrencyIsoCode,UOM__c from Opportunity_Product__c where Opportunity_Name__c =:existingProj.Id];
                
                //System.Debug(' Start OP Size ' + OP.size());
                if(OP != null){
                    for(Opportunity_Product__c opr : OP){
                        
                        Project_Product__c newPP = new Project_Product__c(Project__c=existingProj.id,Product__c=opr.Product__c,
                            Quantity__c=opr.Quantity__c,Sales_Price__c=opr.Sales_Price__c,Margin__c=opr.Margin_1__c,
                            CurrencyIsoCode=opr.CurrencyIsoCode,UOM__c=opr.UOM__c);
                        insert newPP;
                        //System.Debug(' LPPP ' + newPP.id);
                    }
                }
            
                oppn.Convert_to_Project__c=true;
                update oppn;
                oppPage= new ApexPages.StandardController(existingProj).view();
                oppPage.setRedirect(true);
                return oppPage;
                
            }else{
                ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR, 'Please select an existing project!');
                ApexPages.addMessage(myMsg);
            }
        }  
        return null;        

    }
    
        public PageReference back(){  
            PageReference oppnPage = new ApexPages.StandardController(oppn).view();
            oppnPage.setRedirect(true);
            return oppnPage;
        }
        
        static testMethod void test1(){
         
         Opportunity opp = new Opportunity();
         Account ac = new Account();
         Project__c pro = new Project__c();
        
          
         opp.Name = 'test1';
         opp.Convert_to_Project__c=true;
         opp.CloseDate = System.Today();
         opp.StageName= 'Need Analysis';
         opp.CurrencyIsoCode ='CHF'; 
         opp.StageName= 'Need Analysis';        
         insert opp;
         
         
         pro.Name='test';
         pro.Status__c = 'Active';
         pro.Project_Progress__c='50%';
         pro.Kickoff__c=System.Today();
         pro.Dateline__c=System.Today();
         insert pro;
         
        
         
        
         
        
         
         ProjectCreation pc = new ProjectCreation(new ApexPages.StandardController(opp));
         pc.back();
         pc.saveProject();

Hi All,

 

i have an account object here where i had created a link and when i click the link a VF page comes up.This VF page contain only three fields called Business line,industry cluster and product category.

 

Here the product category depends upon industry cluster and induster cluster depends upon Business line.Since salesforce does not provide dependency on Multiselect pick list.

 

Here the problem what i am facing is like i want to create a table where these three multiselect fields should display and when i selct values from "business line" and put it on the selected values , then Industry cluster should show its values depending upon business line values selected.

 

How  can i write a method for dependency and i want to create a save action.

 

In save action when i click save the three multi select vaule should save on acount  "text" field which is a read only.I know i can convert the multiselct picklist to text field by using "valueOf".

 

 

Please help  me doing this .Let me know how i can create a table with those three field and to save this record in account page in text field.My code is below:

 

<apex:page standardController="Account" Extensions="Multiselect" showHeader="true">
  <apex:form >
    <apex:pageBlock >
         <apex:pageBlockTable value="{!account}" var="a">
         <apex:outputText value="Business Line"  />
         <apex:inputField value="{!a.Business_Line__c}" style="width:300px;" />
         
         
         
         <apex:outputText value="Industry Cluster"/>
         <apex:inputField value="{!a.Industry_Cluster__c}" style="width:300px;"/>
        
         
           
         <apex:outputText value="Product Category"/>
         <apex:inputField value="{!a.Product_Category__c}" style="width:300px;"/>
       
         </apex:pageBlockTable>
          <center><apex:commandButton value="Save" action="{!Save}"/></center>
         </apex:pageBlock>
  </apex:form>  
</apex:page>

 

public class Multiselect {
   public Id aid; 
   Public Account acc;
   Private ApexPages.StandardController c;

    public Multiselect(ApexPages.StandardController controller) {
    acc =(Account)controller.getRecord();
     System.debug('nasir:'+ acc );
     c=controller;
  
    aid = c.getRecord().id;
        }
    Public Account getAccount(){
    return acc;
    }
}

 

Hi

 

i have written a trigger.

trigger Duplicate on Case (before insert) {
    EmailMessage em = new EmailMessage();
    Case dupCase;
    boolean duplicate;
    for (Case c : System.Trigger.new) {
        if(c.Subject.contains('Re:')){
            dupCase = c;
            duplicate = true;
            
        }
    }
    
    if(dupCase!=null){
        String dupCaseSubject = dupCase.Subject.substring(3, dupCase.Subject.length());
        System.debug('RII Debug:'+ dupCaseSubject);
        Case myCase = [select id, Subject from Case where CaseNumber ='00001073'];        
        em.ParentId = myCase.id;
        System.debug('RII Debug caseid:'+ em.ParentId);
        //em.Status='New';
        em.Subject = dupCase.Subject;
        em.FromAddress = 'ramesh@rixyncs.co.in';
        em.FromName='Test';
        em.Incoming = true;
        System.debug('RII Debug sub:'+ em.Subject);
        em.TextBody = dupCase.Description;
        insert em;
        System.debug('RII Debug inserted:'+ em);
  }
    if(duplicate){
        dupCase.addError('This is a reply email');
    }
}

 

 

 

He is the scenario like when ever a case is created from 'email to case'.When we open that case there is a related list "Email" in which that email comes and sits in.

 

now if i use email to case mail id and create a case and also cc to some other person.This mail ceates a case and it is also send to the other person.Suppose if the other person know the answer for that case and he replies back to "email to case" mail .For this a new case should not create,instead it should get attached to the "Email" related list.

 

Please help

Hi All,

 

I have written an apex controller and created a visual force page and i had used datatable for this.The master object is Order__c and child is Job__c. Suppose if there are 5 jobs related to an Order.I display this in visual force page by using dataTable.

 

I am not able to get alternate colours for all the 5 jobs.For example if there is 5 jobs and i user green and blue colour for even and odd.Then jobs in data table should display as blue,green ,blue,green,

 

Here is the Visual force page which i had used.

<apex:page standardController="Order__c"  showHeader="false" extensions="PopulateOrderValues" >
  <html>
<head>
<title>Order Received</title>
</head>
<style type="text/css">
c1 { color: #fae1c3; }
c2 { color: #FF0000; }
</style>


<body>


<table width="600" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td><img src="https://c.cs5.content.force.com/servlet/servlet.ImageServer?id=015O00000008wm7&oid=00DO0000000CqOz&lastMod=1320735422000"/></td>
  </tr>
  <tr>

    <td height="70" align="center" valign="top"><font color="#646464" size="5" face="Helvetica, Arial, sans-serif"><Center>THANK YOU FOR YOUR ORDER!</center></font><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">We will send you a notification once your order is ready for shipment.</font></td>
  </tr>
  <tr>
    <td height="30" align="center" valign="top"><img src="" width="600" height="1"/></td>
  </tr>
  <tr>
    <td><table width="600" border="0" cellpadding="0" cellspacing="0">
      <tr>

        <td width="25">&nbsp;</td>
        <td width="550" height="30" valign="top"><font face="Helvetica, Arial, sans-serif" color="#646464" size="3" style="font-size:19px">ORDER INFORMATION</font></td>
        <td width="25">&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><table width="550" border="0" cellspacing="0" cellpadding="0">
          <tr>

            <td width="95"><strong><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">Order number</font></strong></td>
            <td width="180"><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">{!Order__c.Order_ID__c}</font></td>
            <td width="95" rowspan="5" valign="top"><strong><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">Deliver to</font></strong></td>
            <td width="180" rowspan="5" valign="top"><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">{!currentOrder.Account__r.PersonMailingStreet}, {!currentOrder.Account__r.PersonMailingCity},
             {!currentOrder.Account__r.PersonMailingState},{!currentOrder.Account__r.PersonMailingPostalCode},{!currentOrder.Account__r.PersonMailingCountry}, </font></td>
          </tr>
          <tr>
            <td><strong><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">Cost centre</font></strong></td>
            <td><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">{!Order__c.Cost_Center__c}</font></td>
            </tr>
          <tr>

            <td><strong><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">Employee</font></strong></td>
            <td><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">{!currentOrder.Contact__r.Name}</font></td>
            </tr>
          <tr>
            <td><strong><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">Phone</font></strong></td>
            <td><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">{!currentOrder.Account__r.Phone}</font></td>
            </tr>

          <tr>
            <td><strong><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">Email</font></strong></td>
            <td><font face="Helvetica, Arial, sans-serif" color="#646464" size="2" style="font-size:12px">{!Order__c.Contact_Email__c}</font></td>
            </tr>
        </table></td>
        <td>&nbsp;</td>
      </tr>     
     <tr>
        <td>&nbsp;</td>
        <td height="20">&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      nasir
     <style type="text/css">

     .h { width:1000px;
      height:200px;}
      
      </style>

    <apex:form >
    <apex:pageBlock >
    <apex:dataTable value="{!job}" var="j" columns="5"  style="Helvetica, Arial, sans-serif" bgcolor="#fae1c3"  >
    
    <apex:column styleClass="h"  >
                <apex:facet name="header" >Item #</apex:facet>
                <p><apex:outputText value="{!j.Job_ID__c}" styleClass="mystyle"/></p>
    </apex:column>
    <apex:column styleClass="h" >
                <apex:facet name="header">Date</apex:facet>
                <apex:outputField value="{!Order__c.Order_Date__c}"  styleClass="mystyle"/>
    </apex:column>
    <apex:column styleClass="h">
                <apex:facet name="header">Quantity</apex:facet>
                <apex:outputText value="{!j.Quantity__c}"  styleClass="mystyle"/>
    </apex:column>
    <apex:column styleClass="h" >
                <apex:facet name="header">Product</apex:facet>
                
                <Strong><apex:outputText value="EMC Business Card Front"/></Strong>                
                <apex:outputField value="{!j.Front_Template_Name__c}"  styleClass="mystyle"/> 
                
                <Strong><apex:outputText value="Delivery"/></Strong>                
                <apex:outputField value="{!j.Delivery_Country__c}"  styleClass="mystyle"/>
                
                 <Strong><apex:outputText value="Base"/></Strong>                 
                <apex:outputField value="{!j.Material_Type__c}"/>
                
                 <Strong><apex:outputText value="Lamination"/></Strong>                 
                <apex:outputField value="{!j.Lamination__c}"/>
                
                 <Strong><apex:outputText value="Printed Sides"/></Strong>                
                <apex:outputField value="{!j.Printing_Side__c}"/>
                
                 <Strong><apex:outputText value="Dimendions"/></Strong>            
                <apex:outputField value="{!j.Dimension__c}"/>
                
                <Strong><apex:outputText value="Delivery Zone"/></Strong>                
                <apex:outputField value="{!j.Delivery_State__c}"/>
                
                
    </apex:column>
 
    
    <apex:column styleClass="h" >
              <apex:facet name="header">Cost</apex:facet>
              <apex:outputText value="{!j.Item_Price__c}"  styleClass="mystyle"/>
    </apex:column>
   
   </apex:dataTable>
    </apex:pageBlock> 
    </apex:form>  
    
   
   

<table  ALIGN="right" face="Helvetica, Arial, sans-serif" size="2" style="font-size:12px">
<tr>
    <td style="font-size:15px"><Strong><h1>Cost Of Items</h1></Strong></td>
    <td ALIGN="right"><apex:outputText value="{!Order__c.Cost_of_Items__c}"/></td>
</tr> 
<tr>  
    <td style="font-size:15px"><Strong><apex:outputText value="Delivery"/></Strong></td>
    <td ALIGN="right"> <apex:outputText value="{!Order__c.Freight_Cost__c}"/></td>
</tr>    
<tr>
   <td style="font-size:15px"> <Strong><apex:outputText value="Total"/></Strong></td>
    <td ALIGN="right" > <apex:outputText value="{!Order__c.Total_Charges__c}"/></td>
 </tr>
</table>   
      
   
    </table></td>
  </tr> 
  <tr>
    <td height="20">&nbsp;</td>
  </tr>
  <tr>
    <td><img src="" width="600" height="1" style="display:block"/></td>
  </tr>

  <tr>
    <td height="120" ALIGN="center" valign="middle" bgcolor="#E3E3D9"><font face="Helvetica, Arial, sans-serif" color="#646464" size="3" style="font-size:19px">Best regards,The EfficientLive Team</font></td>
  </tr>
</table>


</body>
</html>

</apex:page>

 and controller is 

public  class PopulateOrderValues {
    public Order__c order;
    public Order__c currentOrder{get;set;}
    public List<Job__c> job{get; set;}

    public PopulateOrderValues(ApexPages.StandardController controller) {
        order=(Order__c)controller.getRecord();
        currentOrder=[Select Contact__r.Email,Contact__r.Name,Account__r.Phone,Account__r.PersonMailingCity,Account__r.PersonMailingCountry,
        Account__r.PersonMailingPostalCode,
        Account__r.PersonMailingState,Account__r.PersonMailingStreet from Order__c where id=:Order.id];
        
        job=[Select  id,Job_ID__c,Order_Date__c,Quantity__c,Item_Price__c,Front_Template_Name__c,Delivery_Country__c
        ,Material_Type__c,Lamination__c,Printing_Side__c,Dimension__c,Delivery_State__c from Job__c where Order__c=:order.id ];
        System.debug('Nasir:'+ job);
    }

 Please let me know how can i change the colour for the records.

 

Thanks

Hi,

I am new to salesforce.com apex. I have enabled product scheduling for opportunities. I have created another object where I want to populate the schedule amount and the date.

 

Can anyone please tell me how can I do this. I have a date field & amount filed on the new object [ Revenue Schedule] . All i want to do is write the revenue schedule amount to amount  & Schedule date to date.

 

PLease suggest.

 

Thanks.