• Rick-Proface
  • NEWBIE
  • 25 Points
  • Member since 2009

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 10
    Replies

APEX manual says:

 

To generate an Apex class from a WSDL:

  1. In the application, click Setup | Develop | Apex Classes.
  2. Click Generate from WSDL.
  3. Click Browse to navigate to a WSDL document on your local hard drive or network, or type in the full path. This WSDL document is the basis for the Apex class you are creating and must be 1 MB or less.

I don't anything that says Generate From WSDL.... Where is it located?

 

If you have this plase post a screenshot.

 

Thanks,

Rick

Hi,

 

I'm using this line in my code

 

stat="{! ISPICKVAL(Special_Price_Request__c.Status__c,"Request")}";

 

 And I always get a false answer even though I know the status IS set to Request. Is there a bug or something more I shoudl know????

 

Thanks,

Rick

Hi,

 

I put together some code from examples on the board and and having problems with the test method. The rest of the code works fine in Sandbox, but still this test method fails.  I keep getting "Unable to retrieve object" on the getcontentasPDF statement.  Any help would be appreciated.

 

Here is my code:

 

public with sharing class testing {
	ApexPages.StandardController controller;
	Private id quoteid;
			
   //Class constructor
    public testing (ApexPages.StandardController c)
     {
        controller = c;
                         
     }     
	
		
	/* This action method will create a PDF of the quote, email the quote and add a record to the
	   Activity History table for later review. */
    public PageReference attach() {
         quoteid = System.currentPageReference().getParameters().get('id');
        
        /* Get the page definition */
        PageReference quotePDF = Page.StandardQuotePDF; 
        
        /* set the quote id on the page definition */
        quotePDF.getParameters().put('id',quoteid);
        
        /* get information from quote */
        Quote myQuote = [Select Quote_Email_Text__c,Quote_File_Name__c FROM Quote where Id = :quoteid];
        
        /* generate the pdf blob */
        Blob pdfBlob = quotePDF.getContentAsPDF();
        
        /* create the attachment against the quote */
        Attachment a = new Attachment();
        a.parentId = quoteid;
        a.name= myQuote.Quote_File_Name__c + '.pdf';
        a.body = pdfBlob;
        
        
        //get name and email address for testing
        User you = [Select Email,Name FROM User WheRE Id = :UserInfo.getUserId() LIMIT 1];
        
        //Create Record in Activity History
        Task myTask = new Task(WhatId = quoteid,
        Status='Completed',
        Subject='Quote Sent by Email',
        Description=myQuote.Quote_Email_Text__c + '\nFile Name='+myQuote.Quote_File_Name__c + '.pdf');
        insert myTask;
        
        
        //Create and attachment
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage (); 
        email.setSaveAsActivity(true);
        email.setToAddresses(new String[]{you.Email});
        email.setSenderDisplayName(you.Name);
        email.setSubject('Pro-face Quotation');
        email.setPlainTextBody(myQuote.Quote_Email_Text__c);
        //email.setHtmlBody('Dear Pro-face America customer,<br /> Your personalized quote is attached. <br />If you need any assistance please email customercare@profaceamerica.com.');
        
      //Create an email attachment
        Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
      //Set name of PDF 
        efa.setFileName(myQuote.Quote_File_Name__c+'.pdf'); 
      //Set body of PDF
        efa.setBody(pdfBlob); 
      //Attach the PDF to your email
        email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});
    
    //  Send email 
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
        
        /* insert the attachment & return to Opportunity*/
        insert a;
        
        /* send the user back to the quote detail page */
        return controller.view();
    }
    
//******************
//Test Method 
//******************
   public static testMethod void TestattachQuote() {
  

    // Insert test Opportunity
      Opportunity testOppty = new opportunity (
       Name = 'Test Opportunity',
       Amount = 50, 
       StageName = 'Closed Won',
       Annual_Quantity__c = 2,
       CloseDate = System.today());
       insert testOppty;
       
    // Insert test Quote
   	   Quote testQuote = new Quote (
       Name = 'Test Quote2',
       OpportunityId = testOppty.Id,
       //OpportunityId = '0068000000VFfSN',
       SAP_Code__c ='C000000');
       insert testQuote;
       
    // Instantiate VisualForce Page
        PageReference pg = Page.StandardQuotePDF; 
        Test.setCurrentPage(pg); 
        ApexPages.currentPage().getParameters().put('id', testQuote.id);
    
    // Instantiate attachQuote controller
       ApexPages.StandardController c = new ApexPages.standardController(testQuote);
       
       testing qe = new testing(c);
       qe.attach();
    
   }

}

 

 

 

I'm gettting a Fatal Error in Sales Force and I'm not sure what this means. Here's the class I have in Eclipse, it is a chunk taken from another class that I wanted to shorten as I only need this functionality.

 

Thanks for any help.

 

 

public with sharing class attachQuoteSPF {
	private ApexPages.StandardController controller;
	Private id quoteid;
			
    public attachQuoteSPF (ApexPages.StandardController c)
     {
        controller = c;
        quoteid = c.getRecord().id;                  
     } 
	
		
	/* The action method that will generate a PDF document from the QuotePDF page and attach it to 
       the quote provided by the standard controller. Called by the action binding for the attachQuote
       page, this will do the work and take the user back to the quote detail page. */
    public PageReference attach() {
        /* Get the page definition */
        PageReference quotePDF = Page.SpecialPricePDF; 
        
        /* set the quote id on the page definition */
        quotePDF.getParameters().put('id',quoteid);
        
        /* generate the pdf blob */
        Blob pdfBlob = quotePDF.getContentAsPDF();
        
        /* create the attachment against the quote */
        Attachment a = new Attachment(parentId = quoteid, name= 'quotePDF.pdf', body = pdfBlob);
        
        /* insert the attachment */
        insert a;
        
        /* send the user back to the quote detail page */
        return controller.view();
    }
    
//******************
//Test Method 
//******************
   public static testMethod void TestattachQuoteSPF() {
    
    // Insert test Quote
   	   Quote testQuote = new Quote (
       Name = 'Test Quote2',
       OpportunityId = '0068000000VFfSN',
       SAP_Code__c ='C000000');
       insert testQuote;
       
    // Instantiate VisualForce Page
        PageReference pg = Page.SpecialPricePDF; 
        Test.setCurrentPage(pg); 
        ApexPages.currentPage().getParameters().put('id', testQuote.id);
    
    // Instantiate attachQuote controller
       ApexPages.StandardController c = new ApexPages.standardController(testQuote);
       attachQuoteSPF qe = new attachQuoteSPF(c);
       qe.attach();
   }

}

 

Hi,

 

I have been searching around on here and seem to find snippets of what I am looking for but being new I'm not sure how to implement them. I'm looking for a complete solution example on creating a pdf and attaching it to an object. Can anyone help me? I think seeing the complete solution will help me learn how they work together.

 

Thanks for any help,

 

Rick

Looking through the manual I found an example and so I coded up this to tell whether my record is activated or open. This always returns false (0) and I cannot figure out why.  Thanks for any help....

 

<html>

<head>
<title>Lock Child Records</title>
<link rel="stylesheet" href="style.css" type="text/css" />

<script language="javascript"  type="text/javascript">
//determine if the header record is active
function init()
{
       
    if(parseInt({!IF( ISPICKVAL( SPF_Header__c.Status__c , "Activated") ,1,0)}))
   {
      alert("Record is locked from adding any more products.");
   }   
    else
   {
      alert("Record is not locked from adding any more products.");
   }
}
</script>
</head>
<body onLoad="init()">
</body>
</html>

Hi,

 

This formula works in my other programs ,but it seems SF is different. I just want to calculate the price base on a discount. I created a formula field with currency as the output and entered this formula:

 

((100- Part_Number__r.Discount_Percent__c)/100)* Part_Number__r.Temp_Price__c

 

The discount is 20% and it never calculates correctly. 

 

Any suggestions as I am new to Sales Force.

 

Thanks!

Rick

Hi, I'm new to Salesforce development and would like someone to point me in the right direction for the project I have been assigned.

 

My project is fairly simple. I want to click a button on a SF page and open a new window to a web page I already have that lists our part numbers. Then the user would be able to select a part and then this number would populate a field back on the SF page. Our part numbers change alot and importing all of them into SF would be a nightmare.

 

I've been looking at the SF documentation and there are alot of different options for development, but I'm having a hard time figuring out which path I should pursue.

 

Thanks to all who reply.

 

 

APEX manual says:

 

To generate an Apex class from a WSDL:

  1. In the application, click Setup | Develop | Apex Classes.
  2. Click Generate from WSDL.
  3. Click Browse to navigate to a WSDL document on your local hard drive or network, or type in the full path. This WSDL document is the basis for the Apex class you are creating and must be 1 MB or less.

I don't anything that says Generate From WSDL.... Where is it located?

 

If you have this plase post a screenshot.

 

Thanks,

Rick

Hi,

 

I'm using this line in my code

 

stat="{! ISPICKVAL(Special_Price_Request__c.Status__c,"Request")}";

 

 And I always get a false answer even though I know the status IS set to Request. Is there a bug or something more I shoudl know????

 

Thanks,

Rick

Hi,

 

I put together some code from examples on the board and and having problems with the test method. The rest of the code works fine in Sandbox, but still this test method fails.  I keep getting "Unable to retrieve object" on the getcontentasPDF statement.  Any help would be appreciated.

 

Here is my code:

 

public with sharing class testing {
	ApexPages.StandardController controller;
	Private id quoteid;
			
   //Class constructor
    public testing (ApexPages.StandardController c)
     {
        controller = c;
                         
     }     
	
		
	/* This action method will create a PDF of the quote, email the quote and add a record to the
	   Activity History table for later review. */
    public PageReference attach() {
         quoteid = System.currentPageReference().getParameters().get('id');
        
        /* Get the page definition */
        PageReference quotePDF = Page.StandardQuotePDF; 
        
        /* set the quote id on the page definition */
        quotePDF.getParameters().put('id',quoteid);
        
        /* get information from quote */
        Quote myQuote = [Select Quote_Email_Text__c,Quote_File_Name__c FROM Quote where Id = :quoteid];
        
        /* generate the pdf blob */
        Blob pdfBlob = quotePDF.getContentAsPDF();
        
        /* create the attachment against the quote */
        Attachment a = new Attachment();
        a.parentId = quoteid;
        a.name= myQuote.Quote_File_Name__c + '.pdf';
        a.body = pdfBlob;
        
        
        //get name and email address for testing
        User you = [Select Email,Name FROM User WheRE Id = :UserInfo.getUserId() LIMIT 1];
        
        //Create Record in Activity History
        Task myTask = new Task(WhatId = quoteid,
        Status='Completed',
        Subject='Quote Sent by Email',
        Description=myQuote.Quote_Email_Text__c + '\nFile Name='+myQuote.Quote_File_Name__c + '.pdf');
        insert myTask;
        
        
        //Create and attachment
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage (); 
        email.setSaveAsActivity(true);
        email.setToAddresses(new String[]{you.Email});
        email.setSenderDisplayName(you.Name);
        email.setSubject('Pro-face Quotation');
        email.setPlainTextBody(myQuote.Quote_Email_Text__c);
        //email.setHtmlBody('Dear Pro-face America customer,<br /> Your personalized quote is attached. <br />If you need any assistance please email customercare@profaceamerica.com.');
        
      //Create an email attachment
        Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
      //Set name of PDF 
        efa.setFileName(myQuote.Quote_File_Name__c+'.pdf'); 
      //Set body of PDF
        efa.setBody(pdfBlob); 
      //Attach the PDF to your email
        email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});
    
    //  Send email 
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
        
        /* insert the attachment & return to Opportunity*/
        insert a;
        
        /* send the user back to the quote detail page */
        return controller.view();
    }
    
//******************
//Test Method 
//******************
   public static testMethod void TestattachQuote() {
  

    // Insert test Opportunity
      Opportunity testOppty = new opportunity (
       Name = 'Test Opportunity',
       Amount = 50, 
       StageName = 'Closed Won',
       Annual_Quantity__c = 2,
       CloseDate = System.today());
       insert testOppty;
       
    // Insert test Quote
   	   Quote testQuote = new Quote (
       Name = 'Test Quote2',
       OpportunityId = testOppty.Id,
       //OpportunityId = '0068000000VFfSN',
       SAP_Code__c ='C000000');
       insert testQuote;
       
    // Instantiate VisualForce Page
        PageReference pg = Page.StandardQuotePDF; 
        Test.setCurrentPage(pg); 
        ApexPages.currentPage().getParameters().put('id', testQuote.id);
    
    // Instantiate attachQuote controller
       ApexPages.StandardController c = new ApexPages.standardController(testQuote);
       
       testing qe = new testing(c);
       qe.attach();
    
   }

}

 

 

 

 

Can some one help me to write SOQL to query contact details of account related to opportunity? the below gets me the account details but i need the contact info too. 

 

SELECT
Name,
StageName,
Amount,
Opportunity.Account.Name
FROM
Opportunity

 

  • October 22, 2009
  • Like
  • 0

Hi,

 

This formula works in my other programs ,but it seems SF is different. I just want to calculate the price base on a discount. I created a formula field with currency as the output and entered this formula:

 

((100- Part_Number__r.Discount_Percent__c)/100)* Part_Number__r.Temp_Price__c

 

The discount is 20% and it never calculates correctly. 

 

Any suggestions as I am new to Sales Force.

 

Thanks!

Rick

Hi,

 

I need to add a custom button on a detail field that create a pdf document using the custom object data

and send a mail using a mail template with the created pdf document in attachement.

 

Can anyone suggest me how to implement this.

 

Thanks,

Hello Everyone,

 

First I want to say thanks for such a great forum, I have learned so much here and really appreciate the amazing feedback I always get. It is truly awesome to see the level of expertise out there willing to help us newbies!!!

 

If I might impose one more time on the greater mind-share out there to help me with the following problem, I would be really appreciative. I am a bit stumped, and have been trying to figure this out on my own for over a week with no success.

 

I have just started learning test classes, and have figured out how to instantiate an object and test strings. My issue is that I now have to test a more complex class that is way over my head - it has changing variables, inserts, etc.) and I have no idea how to test for that stuff? The code is below along with my non-test class (it doesn't actually test anything yet as I can't figure out how to set a concrete variable for this!). Any help at all would be appreciated.

 

Thanks in advance for helping me learn.

 

 

public class addSOA { ApexPages.StandardController controller; public addSOA (ApexPages.StandardController c) { controller = c;} public PageReference emailSOA() { // Get the opportunity Id and name Opportunity opportunity = [SELECT id, name,Opportunity_No__c FROM opportunity WHERE Id = :System.currentPageReference().getParameters().get('id')]; // Create PDF // Reference the page, pass in a parameter to force PDF PageReference pdf = new PageReference('/apex/SOApdf' + '?id=' + opportunity.id); pdf.getParameters().put('p','p'); pdf.setRedirect(true); // Grab the PDF! Blob b = pdf.getContent(); // Create the attachment against the Opportunity */ Attachment a = new Attachment(parentId = opportunity.id, name=opportunity.name + '-'+ opportunity.Opportunity_No__c+'-'+'SOA.pdf', body = b); // Insert the attachment insert a; // Create an email Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage (); email.setSaveAsActivity(true); email.setToAddresses(addresses); email.setSenderDisplayName('New Order'); email.setSubject('New SO Approval Created for Opportunity # ' + opportunity.Opportunity_No__c); email.setPlainTextBody('A new SO Approval has been created for ' + opportunity.Name +' , '+ opportunity.Opportunity_No__c+'. The SO Approval is attached.'); email.setHtmlBody('A new SO Approval has been created for' + '&nbsp;'+'<b>'+ opportunity.Name +'&nbsp;'+'</b>'+ opportunity.Opportunity_No__c+'. The SO Approval is attached.'+ ' To view this Opportunity <a href=https://na1.salesforce.com/'+ opportunity.Id +'><b>click here</b></a>'); // Create an email attachment Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment(); // Set name of PDF efa.setFileName(opportunity.Opportunity_No__c+'SOA.pdf'); // Set body of PDF efa.setBody(b); // Attach the PDF to your email email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa}); // Send email & return to Opportunity Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email}); // Send the user back to the opportunity detail page */ return controller.view(); } String[] addresses = new String[]{}; public List<SelectOption> getItems() { List<SelectOption> options = new List<SelectOption>(); options.add(new SelectOption('aabimanan@krausglobal.com','Amu Abimanan')); options.add(new SelectOption('bfoster@krausglobal.com','Brian Foster')); options.add(new SelectOption('cdamiani@krausglobal.com','Chris Damiani')); options.add(new SelectOption('dpatel@krausglobal.com','Dev Patel')); options.add(new SelectOption('galdea@krausglobal.com','Gabriel Aldea')); options.add(new SelectOption('jwebb@krausglobal.com','Jason Webb')); options.add(new SelectOption('jdelcampo@krausglobal.com','Julian del Campo')); options.add(new SelectOption('mmandilaras@krausglobal.com','Manny Mandilaras')); options.add(new SelectOption('nestey@krausglobal.com','Norm Estey')); options.add(new SelectOption('ptopolnitsky@krausglobal.com','Penny Topolnitsky')); options.add(new SelectOption('rreimer@krausglobal.com','Roger Reimer')); options.add(new SelectOption('rdevisser@krausglobal.com','Ross Devisser')); options.add(new SelectOption('sbailey@krausglobal.com','Scott Bailey')); options.add(new SelectOption('slangan@krausglobal.com','Shannon Langan')); return options; } public String[] getAddresses() { return addresses; } public void setAddresses(String[] addresses) { this.addresses = addresses; } //****************** //Test Method //****************** public static testMethod void TestAddSOA() { // Insert test Opportunity Opportunity testOppty = new opportunity ( Name = 'Test Opportunity', Amount = 5000, StageName = 'Closed Won', CloseDate = System.today()); insert testOppty; // Instantiate VisualForce Page PageReference pg = Page.SOApdf; Test.setCurrentPage(pg); ApexPages.currentPage().getParameters().put('id', testOppty.id); // Instantiate addSOA controller ApexPages.StandardController c = new ApexPages.standardController(testOppty); addSOA qe = new addSOA(c); } }

 

 

 

Hi, I'm new to Salesforce development and would like someone to point me in the right direction for the project I have been assigned.

 

My project is fairly simple. I want to click a button on a SF page and open a new window to a web page I already have that lists our part numbers. Then the user would be able to select a part and then this number would populate a field back on the SF page. Our part numbers change alot and importing all of them into SF would be a nightmare.

 

I've been looking at the SF documentation and there are alot of different options for development, but I'm having a hard time figuring out which path I should pursue.

 

Thanks to all who reply.