• gustavo
  • NEWBIE
  • 0 Points
  • Member since 2010

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

I wrote a code  generating an e-mail with a PDF attachment. I checked the code through the IDE (Eclipse) and all works fine.

Running the same code but using a button in a VisualForce page to activate the method  I received "PDF generation failed. Check the page markup is valid. " message.

The IDE code and the CommandButton code call the same method send().

If instead of getContentAsPDF I use only getContent the Command button works OK.


Following is the code 

 

         }  

    public void send() {

        // Define the email

         Messaging.SingleEmailMessage  email = new Messaging.SingleEmailMessage();   

         Messaging.EmailFileAttachment EFA = new Messaging.EmailFileAttachment();

              if (SP.SPEmail__c!= null)

        {

//         toaddresses = new String []{SP.SPEmail__c};

//        String[] CCaddresses ='gustavo@hotmail.com';

       

        }

        PageReference newPage = new PageReference(QuotaLetter);

        Blob blobFormPDF = null;

            system.debug('******LLEGUE******');

       if (!Test.isRunningTest()){//unable to call .getContent() within tests

            blobFormPDF = newPage.getContentAsPDF();

        } 

        //String[] toAddresses = addresses.split(':', 0);

        // Sets the paramaters of the email

        email.setReplyTo(replyto);

        email.setSubject( subject );

        email.setToAddresses( toaddresses );

        email.setCcAddresses (ccaddresses);       

 //       email.setToAddresses(new String[] { EMAIL_ADDRESS });

 //     email.setPlainTextBody( body );

        email.setPlainTextBody( 'This is the message body' );

//      Set the Attachment

        EFA.setFileName(FileName);

        EFA.setBody(blobFormPDF);

        email.setFileAttachments(new Messaging.EmailFileAttachment[]{EFA});

        // Sends the email

        Messaging.SendEmailResult [] r =

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

       if (r[0].isSuccess()==True){

         estado_del_email='Sent';

         system.debug('****SENT*****');

 

Next is the code used in the IDE

 

            Public sendEmail SE=new sendEmail();

  SE.replyto = 'gustavopipman@hotmail.com';

    SE.toaddresses.add( 'gustavopipman@hotmail.com');

    SE.ccaddresses.add('gustavopipman@hotmail.com');

    SE.subject = 'Gustavo Pipman Quota Letter 2012';

    SE.FileName= 'Gustavo Pipman Quota Letter 2012';

    SE.QuotaLetter = 'https://c.na7.visual.force.com/apex/Sale_People_Letter?id=a01A0000008tEJ3';

SE.send();

 

And finnally is the code belonging to the action of the commandbutton

 

   

     Public void sendemail(){

    SalesPeople = [select name from Sale_Manager__c where name = :SMN];

    SE.replyto = 'gustavopipman@hotmail.com';

    SE.toaddresses.add( 'gustavopipman@hotmail.com');

    SE.ccaddresses.add('gustavopipman@hotmail.com');

    SE.subject = 'Gustavo Pipman Quota Letter 2012';

    SE.FileName= 'Gustavo Pipman Quota Letter 2012';

    SE.QuotaLetter = 'https://c.na7.visual.force.com/apex/Sale_People_Letter?id=a01A0000008tEJ3';

    SE.send();

    update SalesPeople ;

 

I also add the Page code with commandButton

 

</apex:page>

<apex:page controller="SalesPeopleMethods"   title="SPsetinfo" action="{!SPsetinfo}" sidebar="False">

    <apex:form >

               <apex:pageBlock >

<table border ='2' width='250' height='100'>

<tr> <th width='70%' height='70'>Food</th>

<th>Drink</th> <th>Sweet</th></tr>

<tr> <td>A</td> <td>B</td> <td>C</td></tr>

</table>

                     <apex:dataTable value="{!SalesPList}" var="b"   columns="2" width="200px"

                     columnsWidth="90px,10px">

                           <apex:column headerValue="Name" width="95%">   

                            <apex:outputField value="{!b.name}"/>

            </apex:column>  

                           <apex:column headerValue="Earning" width="5%" >   

                            <apex:inputField value="{!b.Earning_Commission__c}"/>

            </apex:column>   

                          <apex:column headerValue="send Email" width="5%" >   

                            <apex:commandLink action="{!sendemail}" >

                            <apex:param name="SMN"  value="{!b.name}" assignTo="{!SMN}"/>

                            <apex:commandButton value="email to {!b.name}"/>

                </apex:commandLink>

            </apex:column>   

           </apex:dataTable>

              </apex:pageBlock>

       </apex:form>

 

  

Hi

 

I have a managed package  that I interested to delete because I can’t change an object name Data Type from  

text(80) to Automatic not allowing me to deploy it in a running installation.


When I click on delete the package I received a  messages that "This package can't be deleted because it have the following uploaded version".

 Then I click on the version where the deprecate button is disabled and a message “you can’t deprecate the latest version of a managed package”.

 

I will appreciate to receive the procedure to roll back my organization without the managed package and without the namespace prefix.

 

Regards



Gustavo 

I'm trying to improve the code coverage in a class that actually is 76%. In the class I have the following code that is not tested :

 

            Public List <SelectOption> buildingListOption  {get{//2&3
            List<selectOption> buildingList =new List<selectOption>();
            for(integer indx_j=0;indx_j<BuildList.size();indx_j++)
                buildingList.add(new selectOption(BuildList[indx_j].id,BuildList[indx_j].name)); 
                return buildingList;
            }//3
            private set;
            }//2
Taking out this code the coverage raised 5%. This code appears twice in the class then its weight is 10% in my code.

My question is how can I test this code.

 

Gustavo

I'm starting working with e-mails through Force.com.

Following is the code I'm running. The strange issue is that the success to send an e-mail depends on the text.

First I tried to send only a message written in the body1 variable without success. Only adding an extra character I succeed to send the e-mail.

 

Didn't succeed
String body1='Eureka';
mail.setPlainTextBody( body1);
Succeed
String body1='Eureka';
mail.setPlainTextBody('1'+ body1);

 

 

 

 

// Create a new single email message object
// that will send out a single email to the addresses in the To, CC & BCC list.
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
// Strings to hold the email addresses to which you are sending the email.
String[] toAddresses = new String[] {'gustavopipman@hotmail.com'};
//String[] ccAddresses = new String[] {'smith@gmail.com'};
// Assign the addresses for the To and CC lists to the mail object.
mail.setToAddresses(toAddresses);
//mail.setCcAddresses(ccAddresses);
// Specify the address used when the recipients reply to the email.
mail.setReplyTo('gustavopipman@hotmail.com');
// Specify the name used as the display name.
mail.setSenderDisplayName('Gustavo Tests');
// Specify the subject line for your email address.
mail.setSubject('E-mail test 12');
// Set to True if you want to BCC yourself on the email.
mail.setBccSender(false);
// Optionally append the salesforce.com email signature to the email.
// The email address of the user executing the Apex Code will be used.
mail.setUseSignature(false);
// Specify the text content of the email.
String body1='Eureka';
mail.setPlainTextBody('1'+ body1);
//mail.setHtmlBody('Your case:<b> ' + case.Id +' </b>has been created<p>'+
//' View case <a href=https://na1.salesforce.com/'+case.Id+'>click here</a>');
// Send the email you have created.
Messaging.sendEmailResult[] r=Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
system.debug(r[0].isSuccess());

// Create a new single email message object// that will send out a single email to the addresses in the To, CC & BCC list.Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();// Strings to hold the email addresses to which you are sending the email.String[] toAddresses = new String[] {'gustavopipman@hotmail.com'};//String[] ccAddresses = new String[] {'smith@gmail.com'};// Assign the addresses for the To and CC lists to the mail object.mail.setToAddresses(toAddresses);//mail.setCcAddresses(ccAddresses);// Specify the address used when the recipients reply to the email.mail.setReplyTo('gustavopipman@hotmail.com');// Specify the name used as the display name.mail.setSenderDisplayName('Gustavo Tests');// Specify the subject line for your email address.mail.setSubject('E-mail test 12');// Set to True if you want to BCC yourself on the email.mail.setBccSender(false);// Optionally append the salesforce.com email signature to the email.// The email address of the user executing the Apex Code will be used.mail.setUseSignature(false);// Specify the text content of the email.String body1='eka';String body2='Eur';mail.setPlainTextBody(body2+ body1);//mail.setHtmlBody('Your case:<b> ' + case.Id +' </b>has been created<p>'+//' View case <a href=https://na1.salesforce.com/'+case.Id+'>click here</a>');// Send the email you have created.Messaging.sendEmailResult[] r=Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });system.debug(r[0].isSuccess());

 

Hi, I'm trying to create a four dimensional array(4 columns, N rows) without success.

I succeed to create a two dimensional array.

Following is the code used

 

List  <List<decimal>> My_array_2D_1=new List  <List<decimal>>();
List  <List<decimal>> My_array_2D_2=new List  <List<decimal>>();
List <List <List<List<decimal>>>> My_array=new List <List <List<List<decimal>>>>();
List <decimal> column_1=new List <decimal>();
List <decimal> column_2=new List <decimal>();
List <decimal> column_3=new List <decimal>();
List <decimal> column_4=new List <decimal>();
column_1.add(1);
column_1.add(2);
column_2.add(10);
column_2.add(20);
column_3.add(100);
column_3.add(200);
column_3.add(1000);
column_3.add(2000);
My_array_2D_1.add(column_1);
My_array_2D_1.add(column_2);
My_array_2D_2.add(column_3);
My_array_2D_2.add(column_4);
//My_array.add(My_array_2D_2);

Without the last line the code runs OK. When I add the last line I receive the following error message :

Compile error at line 20 column 1
Incompatible element type LIST:LIST:Decimal for collection of LIST:LIST:LIST:Decimal

 

I would appreciate if someone can help me to define how to populate the 4D Array (My_array)

 

Gustavo

I'm trying to improve the code coverage in a class that actually is 76%. In the class I have the following code that is not tested :

 

            Public List <SelectOption> buildingListOption  {get{//2&3
            List<selectOption> buildingList =new List<selectOption>();
            for(integer indx_j=0;indx_j<BuildList.size();indx_j++)
                buildingList.add(new selectOption(BuildList[indx_j].id,BuildList[indx_j].name)); 
                return buildingList;
            }//3
            private set;
            }//2
Taking out this code the coverage raised 5%. This code appears twice in the class then its weight is 10% in my code.

My question is how can I test this code.

 

Gustavo

Hi, I'm trying to create a four dimensional array(4 columns, N rows) without success.

I succeed to create a two dimensional array.

Following is the code used

 

List  <List<decimal>> My_array_2D_1=new List  <List<decimal>>();
List  <List<decimal>> My_array_2D_2=new List  <List<decimal>>();
List <List <List<List<decimal>>>> My_array=new List <List <List<List<decimal>>>>();
List <decimal> column_1=new List <decimal>();
List <decimal> column_2=new List <decimal>();
List <decimal> column_3=new List <decimal>();
List <decimal> column_4=new List <decimal>();
column_1.add(1);
column_1.add(2);
column_2.add(10);
column_2.add(20);
column_3.add(100);
column_3.add(200);
column_3.add(1000);
column_3.add(2000);
My_array_2D_1.add(column_1);
My_array_2D_1.add(column_2);
My_array_2D_2.add(column_3);
My_array_2D_2.add(column_4);
//My_array.add(My_array_2D_2);

Without the last line the code runs OK. When I add the last line I receive the following error message :

Compile error at line 20 column 1
Incompatible element type LIST:LIST:Decimal for collection of LIST:LIST:LIST:Decimal

 

I would appreciate if someone can help me to define how to populate the 4D Array (My_array)

 

Gustavo