• ElcalvoMike
  • NEWBIE
  • 55 Points
  • Member since 2008

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 26
    Replies

Please forgive me for absolute newbishness. Only have done couple of Visualforce pages for e-mail templates and some validation rules. Now I need to get this trigger done.

 

I need to have a custom field in Leads that has a count of Activities in Activity History. Usually I would do that with roll-up field, but it is not available in leads.

 

I found a trigger in these forums:

trigger Activity_count on Task (after insert, after update) {
List<Lead> uplist=new List<Lead>();
List<Lead> lelist=[select id,Activity_count__c from Lead];
List<AggregateResult> st=new List<AggregateResult>();
st=[select count(Id),whoid from task where id=:Trigger.new and status='Completed' group by whoid];
for(Integer i=0;i<st.size();i++)
{
for(Lead l:lelist)
{
if(l.id==st[i].get('whoid'))
{
l.Activity_count__c=(Integer)st[i].get('expr0')+l.Activity_count__c;
uplist.add(l);
}
}
}
update uplist;
}

 But problem is that I get following error:

Average test coverage across all Apex Classes and Triggers is 0%, at least 75% test coverage is required.

 

Could you help me out?

Hi All,

 

      I see Created Date in salesforce UI as 9/8/2011 9:00 AM whereas when u query or do data export u see Created Date as 2011-09-08T13:00:21.000Z .Any one knows  why this difference ?

 

Thanks

I would like a way to keep a flow in a primary tab but be able to open other pages in a separate primary tab.

We have a very specific set of VF email pages that I would like to display and keep in the console as opposed to opening a new window as well as displaying full Account/Contact/Opportunity records.

 

I don't see anyway to implement JS srcUp for example within the cloud designer.

 

Thanks for any help here.

 

Mike

Is it possible to return multiple records within Flow designer on a lookup?

I have not seen a way to loop through result set and assign to a variable[0,1,2...] which could be displayed on a text screen.

This seems like a layup but cant figure out the syntax.

Since I cant use a formula field to reference cross-objects on standard objects (we like the case to be related to the opportunity) I need to populate two fields that I will use in a simple mail template.

How do i reference the value that is in case field Order_Number__c?

trigger addOppFields on Case (before insert) {
Case mycase=trigger.new[0];
Opportunity opp=[select ID,Webpartner__c from Opportunity where name = :mycase.Order_Number__c];
mycase.XMWebPartner__c=opp.Webpartner__c;
mycase.Merge_OpportunityID__c=opp.ID;

 

I have created a custom controller and VF page that allows me to chose a number of templates via a dropdown (thanks Bob for the help on conditional rendering) and send that page as an email (and edit before sending if needed)

 

I would like to use this same code to auto send this page from a trigger.

Is there some method for calling  a VF page and get the retuned result of it?

 

currently the controller takes the vars from the URL like /apex/display_email?id=someoppid&body=nameofcomponenet

 

controller (apologies for messy code as I fumble through this)

 

public class opportunityCustomController{ 
private final Opportunity o;
private final Tracking_Information__c tInfo;
private final string component;
private final Emails_Subject_And_Body__c objEBody;
Public string qBody{ get; set; }
Public string emailtype;
public string subject{get; set;}
public string messageBody{get; set;}
private string auto{get; set;}

public opportunityCustomController(){
        auto= Apexpages.currentPage().getParameters().get('auto');     
        o=[select ID,Name,address1__c,address2__c,shipAddrType__c,Amount_Net__c,Cancelled__c,chkAmount__c,chkNumber__c,chkRecd__c,chkDate__c,city__c,Company__c,country__c,cPONum__c,cShippingInfo__c,custID__c,CustomerArt__c,email__c,shippingemail__c,EstDelEndDate__c,EstDelStartDate__c,EstShipMethod__c,ExpectedShipDate__c,fax__c,shippingfax__c,fname__c,handling__c,InvoiceSent__c,iocd_text__c,iOrderCustDetailPk__c,IS_CC__c,Is_CreditCard_declines__c,isFromUnviersalQuote__c,isOnCreditHold__c,Lead_Time__c,lname__c,LogoUploaded__c,OrderDate__c,OrderInstructions__c,phone__c,shippingphone__c,POSent__c,PromoCode__c,rebate__c,rebate_desc__c,Redo__c,Remarks__c,ReOrder__c,shipping__c,shippingaddress__c,shippingaddress2__c,shippingcity__c,shippingcompany__c,NetShippingCost__c,shippingcountry__c,shippingfname__c,shippinglname__c,shippingstate__c,shippingtitle__c,shippingzip__c,state__c,tax__c,Title__c,VisitorId__c,WebPartner__c,webpartnerOID__c,XMQuoteNo__c,zip__c,(Select Id, IsPrimary, Contact.Name, Contact.Email From OpportunityContactRoles Where IsPrimary=TRUE)
          from Opportunity where id = : Apexpages.currentPage().getParameters().get('id')];
      component=Apexpages.currentPage().getParameters().get('body');
       tInfo=[select Adjustment_Billed__c,Adjustment_Incentive__c,AutoID__c, Billed_Charge__c,Incentive_Credit__c,
                        Opportunity__c,Receiver_Zip__c,Reference_1__c,Reference_2__c,Sender_Company_Name__c,Sender_Zip__c,
                        Service_Level__c,Shipping_Type__c,Tracking_Link__c, Tracking_Number__c,Vendor__c,Web_Order_Number__c,
                        Weight__c,Zone__c
                        from Tracking_Information__c where Web_Order_Number__c ='MPP-190'];
                        
        //qBody = String.ValueOf(Apexpages.currentPage().getParameters().get('body'));
        emailtype=String.ValueOf(Apexpages.currentPage().getParameters().get('body'));
        subject = emailtype.Replace('/','');
        
        if(auto == '1'){
            pagereference objP = send();
        }
}

public Opportunity getOpportunity(){
return o;
}

public string getEmailBody() {
return component;

}

public Tracking_Information__c getTracking(){
return tInfo;
}

public string getemailtype(){
return emailtype;
}

public string getSubject(){
return subject;
}

public string getmessageBody(){
    return messageBody;
}

public string getAutoSend() {
return auto;
}

public List<SelectOption> getItems() {
    List<SelectOption> options = new List<SelectOption>();
    options.add(new SelectOption('shippingupdate','shippingupdate'));
    options.add(new SelectOption('trackinginfo','trackinginfo'));
    return options;
}
    
public void SendEmail() {
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTargetObjectId('003Q000000LIUOB');
mail.setTemplateId('00XQ0000000MGee');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}

public PageReference send() {
    // Define the email
    Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
    String addresses;
   // addresses = String.valueOf(o.get('email__c')); //Need to open this comment
   addresses = 'rupesh@smartsign.co.in';
    String[] toAddresses = addresses.split(':', 0);
    // Sets the paramaters of the email
    email.setSubject(subject);
    email.setToAddresses(toAddresses);
    /*email.setPlainTextBody( body );*/
    email.setHtmlBody(messageBody);
    // Sends the email
    Messaging.SendEmailResult [] r =
    Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
    return null;
    //PageReference objPage = new PageReference(Apexpages.currentPage().getParameters().get('retURL'));
    //objPage.setRedirect(true);
    //return objPage;
}

}

 

 

 

 

page

 

<apex:page controller="opportunityCustomController">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    </head>
    <style type="text/css">
        <!-- place inline css here from companies table -->
    </style>

    <body>
    <div id="dvMain" style="display:none;">
        <table width="600" cellspacing="0" cellpadding="0" border="0" bgcolor="#FFFFFF" align="center" >
            <!-- This holds mast for emails. Should be a self enclosed table that floats here. -->
            <tr>
                <td>
                     <table width="100%"  cellspacing="0" cellpadding="0" border="0" bgcolor="#FFFFFF" align="center" >
                        <tr>
                            <td width="50%"  align="left" valign="top" cellspacing="0" cellpadding="0" border="0" bgcolor="#FFFFFF">
<a href="http://www.{!Opportunity.WebPartner__c}.com" border="0"><img src="http://www.smartsign.com/companies/logos/{!Opportunity.WebPartner__c}_logo.gif" border = "0" alt="{!Opportunity.WebPartner__c} logo" /></a>
                            </td>
                            <td width="50%" align="right" valign="top" cellspacing="0" cellpadding="0" border="0" bgcolor="#FFFFFF"><a href="http://www.smartsign.com/aboutus.aspx" border="0"><img src="http://www.smartsign.com/companies/logos/a_smartsign_store.gif" border = "0" alt="Learn more about SmartSign" /></a>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
              <td>
                    <c:ShippingUpdate id="ShippingUpdate" rendered="{!IF(emailtype=="/shippingupdate", true, false)}"/>         
                    <c:TrackingInfo id="TrackingInfo" rendered="{!IF(emailtype=="/trackinginfo", true, false)}"/> 
                    <c:forgotpassword id="ForgotPassword" rendered="{!IF(emailtype=="/forgotpassword", true, false)}"/> 
                    <c:OrderConfirmation id="OrderConfirmation" rendered="{!IF(emailtype=="/orderconfirmation", true, false)}"/>   
                </td>
            </tr>
            <!-- This holds footer for emails. Should be a self enclosed table that floats here. -->
            <tr>
                <td>
                   <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr> 
                <td valign="middle" align="left">
                    <IMG src="http://www.smartsign.com/companies/{!Opportunity.WebPartner__c}/arrow_orange.gif" width="4" height="6" alt=""/> <a href="http://www.{!Opportunity.WebPartner__c}.com/xp/policies.asp" title="Policies">Policies</a>
                    &nbsp;&nbsp;<IMG src="http://www.smartsign.com/companies/{!Opportunity.WebPartner__c}/arrow_orange.gif" width="4" height="6" alt=""/> <a href="http://www.{!Opportunity.WebPartner__c}.com/Asset-Tags-FAQ.aspx" title="Frequently Asked Questions">FAQs</a>
                    &nbsp;&nbsp;<IMG src="http://www.smartsign.com/companies/{!Opportunity.WebPartner__c}/arrow_orange.gif" width="4" height="6" alt=""/> <a href="http://www.{!Opportunity.WebPartner__c}.com/material_specs.aspx" title="Material Specifications">Material Specs</a>
                    &nbsp;&nbsp;<IMG src="http://www.smartsign.com/companies/{!Opportunity.WebPartner__c}/arrow_orange.gif" width="4" height="6" alt=""/> <a href="http://www.{!Opportunity.WebPartner__c}.com/aboutus.aspx" title="About Us">About Us</a>
                    &nbsp;&nbsp;<IMG src="http://www.smartsign.com/companies/{!Opportunity.WebPartner__c}/arrow_orange.gif" width="4" height="6" alt=""/> <a href="http://www.{!Opportunity.WebPartner__c}.com/Asset-Tags-Testimonials.aspx" title="Testimonials">Testimonials</a>
                    &nbsp;&nbsp;<IMG src="http://www.smartsign.com/companies/{!Opportunity.WebPartner__c}/arrow_orange.gif" width="4" height="6" alt=""/> <a href="http://www.{!Opportunity.WebPartner__c}.com/xp/ContactUs.aspx" title="Contact Us">Contact Us</a>
                    &nbsp;&nbsp;<IMG src="http://www.smartsign.com/companies/{!Opportunity.WebPartner__c}/arrow_orange.gif" width="4" height="6" alt=""/> <a href="http://www.{!Opportunity.WebPartner__c}.com/xp/disclaimer.asp" title="Disclaimer">Disclaimer</a>
                    &nbsp;&nbsp;<IMG src="http://www.smartsign.com/companies/{!Opportunity.WebPartner__c}/arrow_orange.gif" width="4" height="6" alt=""/> <a href="http://www.{!Opportunity.WebPartner__c}.com/site-map.aspx" title="My Asset Tag Site Map">Site Map</a></td>
                <td align="right">&copy; 2011, {!Opportunity.WebPartner__c}.com</td>
            </tr>
        </table>
                </td>
            </tr>
        </table>
    </div>    
    <apex:form id="frmTxtArea">
        <table width="100%" border="0" cellspacing="3" cellpadding="3" style="padding-top:25px;"> 
            <tr>
                <td>
                    <b> Subject</b> <br />
                    <apex:inputText value="{!subject}" id="Subject" maxlength="80"/><br /><br />
                    <apex:selectList id="ddlBody" value="{!subject}" multiselect="false" size="1" onchange="getBodyValue()">
                        <apex:selectOptions value="{!Items}"></apex:selectOptions>
                    </apex:selectList><br />
                </td>
            </tr>                   
           <tr>               
               <td>
                   <b>Message Body </b> <br />
                   <apex:inputTextarea id="txtAreaBody" value="{!messageBody}" richText="true" rows="30" cols="20"/>
               </td>
           </tr>
           <tr>
               <td>
                   <apex:commandButton value="Send Email" action="{!send}" immediate="{!IF (autosend=="1",true,false)}" />
               </td>
           </tr>
       </table>
   </apex:form>
    </body>
    <script>
        var comp = document.getElementById("dvMain");
        var txtAreaBody = document.getElementById("{!$Component.frmTxtArea:txtAreaBody}");
        txtAreaBody.value = comp.innerHTML;
        
        function getBodyValue()
        {
            var sSubject = ("&body=" + "{!subject}");//alert("sSubject" + sSubject);
            var sValue = document.getElementById("{!$Component.frmTxtArea:ddlBody}");
            var sSelectedValue = sValue.options[sValue.selectedIndex].value;
            //alert("sSelectedValue " + sSelectedValue);
            var cLocation = window.location.href;
            var nSubject = ("&body=" + sSelectedValue); //alert("nSubject" + nSubject);
            var nLocation = cLocation.replace(sSubject, nSubject);//alert("cLocation " + cLocation);
            //alert("nLocation " + nLocation );
            window.location = nLocation;
        }
    </script>
</html>
</apex:page>

 

I have a custom controller that returns the name of a component.

 

I want to then insert this component like so into an existing page.

<apex:insert name="{!templatename}" />

 

However insert will only accept a literal. Is there another way to do this?

We maintain about 50 brands within our company and I would like to have a standard email template where the brand logo would swap out AND the body of the email (not the header and footer) would be inserted at send. The problem I have had is that I CANNOT get the body to work with the controller. I want to be able to create a template and reference any field  like {!opp.companyname__c}_logo,jpg for example. Right now I am using objects to retrieve the parts but this doesnt connect it with the controller. How can I approch this in a better way?

 

Code:

public class oppSendMail{
    public string subject { get; set; }
    public string body { get ; set; }
    private final Opportunity oppo { get ; set; }
    private final Account acc;
    private final OpportunityEmailHtml__c objHTML;
    private final Emails_Subject_And_Body__c objESB;
    private string webPartner {get; set; }
    
    public oppSendMail(){
           oppo=[select ID,Name,etc];

        objHTML = [select EmailHtml__c from OpportunityEmailHtml__c where Name = : 'GlobalET'];
        
        objESB = [select Body__c, Subject__c from Emails_Subject_And_Body__c where Name =: 'Hold' Limit 1];
        
        subject = String.valueOf(objESB.get('Subject__c'));
        body = String.valueOf(objHTML.get('EmailHtml__c'));
        webPartner = String.valueOf(oppo.get('WebPartner__c'));
        body = body.Replace('{!OppBasic.WebPartner__c}', webPartner);
        body = body.Replace('@Message', String.valueOf(objESB.get('Body__c')));
    }
    
    public Opportunity getOppBasic(){
        return oppo;
    }
    
    public OpportunityEmailHtml__c getETBasic(){
        return objHTML;
    }
    
    public PageReference send() {
        // Define the email
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        String addresses;
        addresses = String.valueOf(oppo.get('email__c'));
        String[] toAddresses = addresses.split(':', 0);
        // Sets the paramaters of the email
        email.setSubject( subject );
        email.setToAddresses( toAddresses );
        email.setHtmlBody(body);
        // Sends the email
        Messaging.SendEmailResult [] r =
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
        
        PageReference objPage = new PageReference(Apexpages.currentPage().getParameters().get('retURL'));
        objPage.setRedirect(true);
        return objPage;
    }
}

 

 

I cannot figure out how to reference variables from the controller initiated in the constructor.

I get Variable does not exist: opp.fname__c. However this is the name of this custom field.

Am i not calling this correctly?

 

public class MailClass {
private final Opportunity opp;
public mailClass(ApexPages.StandardController controller)
{
this.opp=(Opportunity)controller.getRecord();
}

static final string Subject='Hi ' + opp.fname__c;

 

 

 

I feel like this should be pretty simple, yet I cannot get it to work.
 
I have a Job Description field (the API field name is Job_Description__c) and I want to create a short description with just the first 20 characters.
This field is populated from  a Web to Lead form.
so..
 
LEFT(Job_Description__c,20)
 
But the syntax error always comes up : Cannot find field Job_Description__c.
 
Can I not use a custom field in another custom field formula?
 
Mike

I would like a way to keep a flow in a primary tab but be able to open other pages in a separate primary tab.

We have a very specific set of VF email pages that I would like to display and keep in the console as opposed to opening a new window as well as displaying full Account/Contact/Opportunity records.

 

I don't see anyway to implement JS srcUp for example within the cloud designer.

 

Thanks for any help here.

 

Mike

Is it possible to return multiple records within Flow designer on a lookup?

I have not seen a way to loop through result set and assign to a variable[0,1,2...] which could be displayed on a text screen.

I am getting an internal server error in my Spring 12 Sandbox for all of my existing flows designed with the old flow designer tool. Is any else experiencing this? 

Please forgive me for absolute newbishness. Only have done couple of Visualforce pages for e-mail templates and some validation rules. Now I need to get this trigger done.

 

I need to have a custom field in Leads that has a count of Activities in Activity History. Usually I would do that with roll-up field, but it is not available in leads.

 

I found a trigger in these forums:

trigger Activity_count on Task (after insert, after update) {
List<Lead> uplist=new List<Lead>();
List<Lead> lelist=[select id,Activity_count__c from Lead];
List<AggregateResult> st=new List<AggregateResult>();
st=[select count(Id),whoid from task where id=:Trigger.new and status='Completed' group by whoid];
for(Integer i=0;i<st.size();i++)
{
for(Lead l:lelist)
{
if(l.id==st[i].get('whoid'))
{
l.Activity_count__c=(Integer)st[i].get('expr0')+l.Activity_count__c;
uplist.add(l);
}
}
}
update uplist;
}

 But problem is that I get following error:

Average test coverage across all Apex Classes and Triggers is 0%, at least 75% test coverage is required.

 

Could you help me out?

This seems like a layup but cant figure out the syntax.

Since I cant use a formula field to reference cross-objects on standard objects (we like the case to be related to the opportunity) I need to populate two fields that I will use in a simple mail template.

How do i reference the value that is in case field Order_Number__c?

trigger addOppFields on Case (before insert) {
Case mycase=trigger.new[0];
Opportunity opp=[select ID,Webpartner__c from Opportunity where name = :mycase.Order_Number__c];
mycase.XMWebPartner__c=opp.Webpartner__c;
mycase.Merge_OpportunityID__c=opp.ID;

 

How do you take a date value and determine if it falls within two other date values?

Hi, 


I recently installed Force IDE and am experiencing some frustrating issues around connectivity behind our corporate firewall. I have read the other posts and ensured that my proxy settings are correct. I have tried Force IDE on a Mac running Lion and on a Windows machine. I have also installed Eclipse and the Force plug-in on both the Mac and the Windows machine and none of the configurations work behind the firewall. Again, my proxy settings are correct. I have the Preferences->Network Connections Active Provider set to Manual and I have a Host and port defined for HTTP and HTTPS.

 

When I create a New Force Project, All the resources come down fine behind the firewall. I see all my classes, etc. Its when I go to make a change (I make a simple string change) and save it, I get 2 exceptions, a BuilderException (Unable to perform save on all files)  and a RetrieveException (Unable to perform conflict check). When I try to refresh from the server, the basic message I get is: "Unable to refresh resource xzy. Connection Refused." The stack traces in the logs are all java connection issues. I am running with java 1.6.  I was not able to pull anything out in the stack trace that would point me to the direction of a fix. 


I try the same exact changes at home, outside the firewall, and all is fine. Change gets saved and I am good to go. So, behind the Firewall, does not work, at home, works fine. I have compared my proxy settings with a co worker and they are exactly the same and his machine works fine.


An insight as to what might be causing this issue would be greatly appreciated!

 

Kevin

Hi All,

 

      I see Created Date in salesforce UI as 9/8/2011 9:00 AM whereas when u query or do data export u see Created Date as 2011-09-08T13:00:21.000Z .Any one knows  why this difference ?

 

Thanks

I have two users, one an administrator and other a more restricted user. Both have full access to my custom objects bus and bus trips.

The bus trips object has a lookup which displays a list of buses with the "In service" attribute checked.

When the admin goes to the lookup and enters * in the search, he sees all the "In service" buses, as expected.

But when the other user does exactly the same lookup, she only sees a single bus.

She can see more buses by entering a few characters of the bus name, so I know she has the rights to see the buses (and she can see all the buses from the "Buses" tab).

 

Has anyone any idea why there is a difference in the way the lookup filter works?

I have created a custom controller and VF page that allows me to chose a number of templates via a dropdown (thanks Bob for the help on conditional rendering) and send that page as an email (and edit before sending if needed)

 

I would like to use this same code to auto send this page from a trigger.

Is there some method for calling  a VF page and get the retuned result of it?

 

currently the controller takes the vars from the URL like /apex/display_email?id=someoppid&body=nameofcomponenet

 

controller (apologies for messy code as I fumble through this)

 

public class opportunityCustomController{ 
private final Opportunity o;
private final Tracking_Information__c tInfo;
private final string component;
private final Emails_Subject_And_Body__c objEBody;
Public string qBody{ get; set; }
Public string emailtype;
public string subject{get; set;}
public string messageBody{get; set;}
private string auto{get; set;}

public opportunityCustomController(){
        auto= Apexpages.currentPage().getParameters().get('auto');     
        o=[select ID,Name,address1__c,address2__c,shipAddrType__c,Amount_Net__c,Cancelled__c,chkAmount__c,chkNumber__c,chkRecd__c,chkDate__c,city__c,Company__c,country__c,cPONum__c,cShippingInfo__c,custID__c,CustomerArt__c,email__c,shippingemail__c,EstDelEndDate__c,EstDelStartDate__c,EstShipMethod__c,ExpectedShipDate__c,fax__c,shippingfax__c,fname__c,handling__c,InvoiceSent__c,iocd_text__c,iOrderCustDetailPk__c,IS_CC__c,Is_CreditCard_declines__c,isFromUnviersalQuote__c,isOnCreditHold__c,Lead_Time__c,lname__c,LogoUploaded__c,OrderDate__c,OrderInstructions__c,phone__c,shippingphone__c,POSent__c,PromoCode__c,rebate__c,rebate_desc__c,Redo__c,Remarks__c,ReOrder__c,shipping__c,shippingaddress__c,shippingaddress2__c,shippingcity__c,shippingcompany__c,NetShippingCost__c,shippingcountry__c,shippingfname__c,shippinglname__c,shippingstate__c,shippingtitle__c,shippingzip__c,state__c,tax__c,Title__c,VisitorId__c,WebPartner__c,webpartnerOID__c,XMQuoteNo__c,zip__c,(Select Id, IsPrimary, Contact.Name, Contact.Email From OpportunityContactRoles Where IsPrimary=TRUE)
          from Opportunity where id = : Apexpages.currentPage().getParameters().get('id')];
      component=Apexpages.currentPage().getParameters().get('body');
       tInfo=[select Adjustment_Billed__c,Adjustment_Incentive__c,AutoID__c, Billed_Charge__c,Incentive_Credit__c,
                        Opportunity__c,Receiver_Zip__c,Reference_1__c,Reference_2__c,Sender_Company_Name__c,Sender_Zip__c,
                        Service_Level__c,Shipping_Type__c,Tracking_Link__c, Tracking_Number__c,Vendor__c,Web_Order_Number__c,
                        Weight__c,Zone__c
                        from Tracking_Information__c where Web_Order_Number__c ='MPP-190'];
                        
        //qBody = String.ValueOf(Apexpages.currentPage().getParameters().get('body'));
        emailtype=String.ValueOf(Apexpages.currentPage().getParameters().get('body'));
        subject = emailtype.Replace('/','');
        
        if(auto == '1'){
            pagereference objP = send();
        }
}

public Opportunity getOpportunity(){
return o;
}

public string getEmailBody() {
return component;

}

public Tracking_Information__c getTracking(){
return tInfo;
}

public string getemailtype(){
return emailtype;
}

public string getSubject(){
return subject;
}

public string getmessageBody(){
    return messageBody;
}

public string getAutoSend() {
return auto;
}

public List<SelectOption> getItems() {
    List<SelectOption> options = new List<SelectOption>();
    options.add(new SelectOption('shippingupdate','shippingupdate'));
    options.add(new SelectOption('trackinginfo','trackinginfo'));
    return options;
}
    
public void SendEmail() {
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTargetObjectId('003Q000000LIUOB');
mail.setTemplateId('00XQ0000000MGee');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}

public PageReference send() {
    // Define the email
    Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
    String addresses;
   // addresses = String.valueOf(o.get('email__c')); //Need to open this comment
   addresses = 'rupesh@smartsign.co.in';
    String[] toAddresses = addresses.split(':', 0);
    // Sets the paramaters of the email
    email.setSubject(subject);
    email.setToAddresses(toAddresses);
    /*email.setPlainTextBody( body );*/
    email.setHtmlBody(messageBody);
    // Sends the email
    Messaging.SendEmailResult [] r =
    Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
    return null;
    //PageReference objPage = new PageReference(Apexpages.currentPage().getParameters().get('retURL'));
    //objPage.setRedirect(true);
    //return objPage;
}

}

 

 

 

 

page

 

<apex:page controller="opportunityCustomController">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    </head>
    <style type="text/css">
        <!-- place inline css here from companies table -->
    </style>

    <body>
    <div id="dvMain" style="display:none;">
        <table width="600" cellspacing="0" cellpadding="0" border="0" bgcolor="#FFFFFF" align="center" >
            <!-- This holds mast for emails. Should be a self enclosed table that floats here. -->
            <tr>
                <td>
                     <table width="100%"  cellspacing="0" cellpadding="0" border="0" bgcolor="#FFFFFF" align="center" >
                        <tr>
                            <td width="50%"  align="left" valign="top" cellspacing="0" cellpadding="0" border="0" bgcolor="#FFFFFF">
<a href="http://www.{!Opportunity.WebPartner__c}.com" border="0"><img src="http://www.smartsign.com/companies/logos/{!Opportunity.WebPartner__c}_logo.gif" border = "0" alt="{!Opportunity.WebPartner__c} logo" /></a>
                            </td>
                            <td width="50%" align="right" valign="top" cellspacing="0" cellpadding="0" border="0" bgcolor="#FFFFFF"><a href="http://www.smartsign.com/aboutus.aspx" border="0"><img src="http://www.smartsign.com/companies/logos/a_smartsign_store.gif" border = "0" alt="Learn more about SmartSign" /></a>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
              <td>
                    <c:ShippingUpdate id="ShippingUpdate" rendered="{!IF(emailtype=="/shippingupdate", true, false)}"/>         
                    <c:TrackingInfo id="TrackingInfo" rendered="{!IF(emailtype=="/trackinginfo", true, false)}"/> 
                    <c:forgotpassword id="ForgotPassword" rendered="{!IF(emailtype=="/forgotpassword", true, false)}"/> 
                    <c:OrderConfirmation id="OrderConfirmation" rendered="{!IF(emailtype=="/orderconfirmation", true, false)}"/>   
                </td>
            </tr>
            <!-- This holds footer for emails. Should be a self enclosed table that floats here. -->
            <tr>
                <td>
                   <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr> 
                <td valign="middle" align="left">
                    <IMG src="http://www.smartsign.com/companies/{!Opportunity.WebPartner__c}/arrow_orange.gif" width="4" height="6" alt=""/> <a href="http://www.{!Opportunity.WebPartner__c}.com/xp/policies.asp" title="Policies">Policies</a>
                    &nbsp;&nbsp;<IMG src="http://www.smartsign.com/companies/{!Opportunity.WebPartner__c}/arrow_orange.gif" width="4" height="6" alt=""/> <a href="http://www.{!Opportunity.WebPartner__c}.com/Asset-Tags-FAQ.aspx" title="Frequently Asked Questions">FAQs</a>
                    &nbsp;&nbsp;<IMG src="http://www.smartsign.com/companies/{!Opportunity.WebPartner__c}/arrow_orange.gif" width="4" height="6" alt=""/> <a href="http://www.{!Opportunity.WebPartner__c}.com/material_specs.aspx" title="Material Specifications">Material Specs</a>
                    &nbsp;&nbsp;<IMG src="http://www.smartsign.com/companies/{!Opportunity.WebPartner__c}/arrow_orange.gif" width="4" height="6" alt=""/> <a href="http://www.{!Opportunity.WebPartner__c}.com/aboutus.aspx" title="About Us">About Us</a>
                    &nbsp;&nbsp;<IMG src="http://www.smartsign.com/companies/{!Opportunity.WebPartner__c}/arrow_orange.gif" width="4" height="6" alt=""/> <a href="http://www.{!Opportunity.WebPartner__c}.com/Asset-Tags-Testimonials.aspx" title="Testimonials">Testimonials</a>
                    &nbsp;&nbsp;<IMG src="http://www.smartsign.com/companies/{!Opportunity.WebPartner__c}/arrow_orange.gif" width="4" height="6" alt=""/> <a href="http://www.{!Opportunity.WebPartner__c}.com/xp/ContactUs.aspx" title="Contact Us">Contact Us</a>
                    &nbsp;&nbsp;<IMG src="http://www.smartsign.com/companies/{!Opportunity.WebPartner__c}/arrow_orange.gif" width="4" height="6" alt=""/> <a href="http://www.{!Opportunity.WebPartner__c}.com/xp/disclaimer.asp" title="Disclaimer">Disclaimer</a>
                    &nbsp;&nbsp;<IMG src="http://www.smartsign.com/companies/{!Opportunity.WebPartner__c}/arrow_orange.gif" width="4" height="6" alt=""/> <a href="http://www.{!Opportunity.WebPartner__c}.com/site-map.aspx" title="My Asset Tag Site Map">Site Map</a></td>
                <td align="right">&copy; 2011, {!Opportunity.WebPartner__c}.com</td>
            </tr>
        </table>
                </td>
            </tr>
        </table>
    </div>    
    <apex:form id="frmTxtArea">
        <table width="100%" border="0" cellspacing="3" cellpadding="3" style="padding-top:25px;"> 
            <tr>
                <td>
                    <b> Subject</b> <br />
                    <apex:inputText value="{!subject}" id="Subject" maxlength="80"/><br /><br />
                    <apex:selectList id="ddlBody" value="{!subject}" multiselect="false" size="1" onchange="getBodyValue()">
                        <apex:selectOptions value="{!Items}"></apex:selectOptions>
                    </apex:selectList><br />
                </td>
            </tr>                   
           <tr>               
               <td>
                   <b>Message Body </b> <br />
                   <apex:inputTextarea id="txtAreaBody" value="{!messageBody}" richText="true" rows="30" cols="20"/>
               </td>
           </tr>
           <tr>
               <td>
                   <apex:commandButton value="Send Email" action="{!send}" immediate="{!IF (autosend=="1",true,false)}" />
               </td>
           </tr>
       </table>
   </apex:form>
    </body>
    <script>
        var comp = document.getElementById("dvMain");
        var txtAreaBody = document.getElementById("{!$Component.frmTxtArea:txtAreaBody}");
        txtAreaBody.value = comp.innerHTML;
        
        function getBodyValue()
        {
            var sSubject = ("&body=" + "{!subject}");//alert("sSubject" + sSubject);
            var sValue = document.getElementById("{!$Component.frmTxtArea:ddlBody}");
            var sSelectedValue = sValue.options[sValue.selectedIndex].value;
            //alert("sSelectedValue " + sSelectedValue);
            var cLocation = window.location.href;
            var nSubject = ("&body=" + sSelectedValue); //alert("nSubject" + nSubject);
            var nLocation = cLocation.replace(sSubject, nSubject);//alert("cLocation " + cLocation);
            //alert("nLocation " + nLocation );
            window.location = nLocation;
        }
    </script>
</html>
</apex:page>

 

i have a doubt,

when i click on hyperlink it opens a page but i want that user cant change the the details of the page means i want that page to be protected, means if one button is there on the page then it should become non clickable means it should not react any event by clicking on it. i want this facility for my entire page, any page mode or any mark ups for that ? which apex provides!!! please tell me fast.if anybody has some solutions for this kind of problem.any kind of help will be appreciated.

thanks in advance 

We maintain about 50 brands within our company and I would like to have a standard email template where the brand logo would swap out AND the body of the email (not the header and footer) would be inserted at send. The problem I have had is that I CANNOT get the body to work with the controller. I want to be able to create a template and reference any field  like {!opp.companyname__c}_logo,jpg for example. Right now I am using objects to retrieve the parts but this doesnt connect it with the controller. How can I approch this in a better way?

 

Code:

public class oppSendMail{
    public string subject { get; set; }
    public string body { get ; set; }
    private final Opportunity oppo { get ; set; }
    private final Account acc;
    private final OpportunityEmailHtml__c objHTML;
    private final Emails_Subject_And_Body__c objESB;
    private string webPartner {get; set; }
    
    public oppSendMail(){
           oppo=[select ID,Name,etc];

        objHTML = [select EmailHtml__c from OpportunityEmailHtml__c where Name = : 'GlobalET'];
        
        objESB = [select Body__c, Subject__c from Emails_Subject_And_Body__c where Name =: 'Hold' Limit 1];
        
        subject = String.valueOf(objESB.get('Subject__c'));
        body = String.valueOf(objHTML.get('EmailHtml__c'));
        webPartner = String.valueOf(oppo.get('WebPartner__c'));
        body = body.Replace('{!OppBasic.WebPartner__c}', webPartner);
        body = body.Replace('@Message', String.valueOf(objESB.get('Body__c')));
    }
    
    public Opportunity getOppBasic(){
        return oppo;
    }
    
    public OpportunityEmailHtml__c getETBasic(){
        return objHTML;
    }
    
    public PageReference send() {
        // Define the email
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        String addresses;
        addresses = String.valueOf(oppo.get('email__c'));
        String[] toAddresses = addresses.split(':', 0);
        // Sets the paramaters of the email
        email.setSubject( subject );
        email.setToAddresses( toAddresses );
        email.setHtmlBody(body);
        // Sends the email
        Messaging.SendEmailResult [] r =
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
        
        PageReference objPage = new PageReference(Apexpages.currentPage().getParameters().get('retURL'));
        objPage.setRedirect(true);
        return objPage;
    }
}