• RedPoint
  • NEWBIE
  • 0 Points
  • Member since 2008

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

Does anyone know if there is a limit on the number of parameters that you can pass to a controller using a commandLink?  I have a commandLink with 15 param names.  When the link is clicked I get random errors because some of my values are null and they should not be. 

 

I removed the some of the param names in the visualforce page and got the values with a query in the controller but now I'm failing my test because I have over 20 queries.

 

Anyone had similar issues?  I know it's the number of parameters because I deleted them individually and I never get errors with a total of 9.

 

Thanks,

 

George Sowards

 

I have a trigger on a custom object.  If this custom object is updated any parent objects that have the custom object as a child are updated.  Everything works fine.  However, the custom object has a formula field that is date specific (i.e. if warranty end date is greater than today then "yes" else "no").  The problem is when the formula field changes to "no" (moving from 12/1 to 12/2), the trigger is not triggered; the change of the result in the formula field does not create an update.  How can I make a formula field make an update so the trigger gets used?

Thanks!


Message Edited by RedPoint on 12-02-2008 10:48 AM
I have written a simple trigger to update the ListPrice of an OpportunityLine item.  The trigger works perfectly in the sandbox and it's very simple.  I cannot deploy it because I get the following error when trying to test it: 

CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, OppLineTrigger: execution of BeforeInsert
caused by: System.NullPointerException: Attempt to de-reference a null object

Here's the trigger:
Code:
trigger OppLineTrigger on OpportunityLineItem (before insert, before update) {
  
 OpportunityLineItem[] oli = Trigger.new;
        for (OpportunityLineItem o:oli){
       Double val = [select Discount__c from Opportunity Where Id = :o.OpportunityId][0].Discount__c;
       o.Description = String.valueOf(val) + '% Discount';
       o.UnitPrice = o.ListPrice - (o.ListPrice*(val/100));
 }   
}

Here's the test class:
Code:
public class testOppLineTrigger {

 static testMethod void testOppLineTrigger() { 
     
    Product2 p = new product2(name='x', Product_Group__c = 'BNN'); 
    insert p;  
    
    Pricebook2 stdPb = [select Id from Pricebook2 where isStandard=true limit 1]; 
    
    insert new PricebookEntry(pricebook2id = stdPb.id, product2id = p.id, 
                              unitprice=10.0, isActive=true); 
     
    Pricebook2 pb = new pricebook2(name='test'); 
    insert pb; 
    PricebookEntry pbe = new PricebookEntry(pricebook2id=pb.id, product2id=p.id, 
                                            unitprice=10, isActive=true); 
    insert pbe; 
    
    Account a = new Account(name='test acct');
    insert a;    
     
    Opportunity test_o = new Opportunity(name='test', AccountId=a.id, pricebook2id=pb.id, 
                                    stageName='Open', Discount__c = 10, 
                                    CloseDate=Date.newInstance(2006,10,10)); 
    insert test_o; 
    OpportunityLineItem test_oli = new OpportunityLineItem(opportunityid=test_o.id, 
                                      pricebookentryid=pbe.id, quantity=2, TotalPrice=20); 
    insert test_oli; 
   
       Double UP = [SELECT UnitPrice FROM OpportunityLineItem WHERE Id =:test_oli.id][0].UnitPrice;

       System.assertEquals(9, UP);               
    
    }

}

 

 

Hello

 

I'm having a strange issue, let me start with my code:

 

VisualForce:

 

<apex:commandButton action="{!sendEmail}" value="Send Email" id="emailButton"> <apex:param name="frmParam" assignTo="{!frm}" value="{!$User.Email}"></apex:param> <apex:param name="toParam" assignTo="{!to}" value="{!Application__c.Email__c}"></apex:param> <apex:param name="subjParam" assignTo="{!subject}" value="Your application for position no. {!Application__c.Job_Requisition__r.name}"></apex:param> </apex:commandButton>

 Controller:

 

public class emailApplicant { private Application__c app; private String jobRef = null; public string frm; public string to; public string subject; public string emailBody; public string getFrm(){ return frm; } public string getTo(){ return to; } public string getSubject(){ return subject; } public string getEmailBody(){ return emailBody; } public void setFrm(string value){ frm = value; } public void setTo(string value){ to = value; } public void setSubject(string value){ subject= value; } public void setEmailBody(string value){ emailBody=value; } public emailApplicant(ApexPages.StandardController controller){ app = (Application__c)controller.getSubject(); //Id id = System.currentPageReference().getParameters().get('id'); jobRef = [SELECT name FROM job_req__c WHERE id = :app.job_requisition__c].name; } public Application__c getAppInfo(){ return app; } public String getJobRef(){ return jobRef; } public PageReference sendEmail(){ PageReference p = new PageReference('https://na6.salesforce.com/'+app.job_requisition__c); p.setRedirect(true); Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); String [] toAddresses = new String[]{to}; mail.setToAddresses(toAddresses); mail.setReplyTo(frm); mail.setSenderDisplayName(frm); mail.setSubject(subject+to+frm); mail.setPlainTextBody(emailBody); Messaging.sendEmailResult[] results = Messaging.sendEmail(new Messaging.SingleEmailMessage[]{mail}); for ( Messaging.sendEmailResult result : results ) { if ( !result.isSuccess () ) { System.debug ( result ); return p; } } return p; } }

 

The issue is that if I use a commandbutton in the VisualForce page I get the following error:

 

 

System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_EMAIL_ADDRESS, Invalid to address : null

 

This value is not null, and I can attest to this because if I simply change the commandButton into a commandLink, the result is positive. Could someone tell me if there is a bug, or if I am using the component incorrectly.

 

Thanks,

Wes

 

 

Hi,

Does anyone know a way to have an inputText field take the action of the commandbutton when the user presses enter?

I have a simple form with one inputtext and one commandbutton. The button just does the action piece. Can I bind an user press on the input text to that action?

Thanks!
  • January 19, 2009
  • Like
  • 0
So, I have a question and the answer could be quite simple but I haven't found it. I am looking to do something that is similar to what the "Salesforce -> Gmail" link does when the App is activated.

I would like to place a link next to a certain type of text... In this case it's next to attachments. So when viewing an attachment and it says, "Click here to view this file", I'd like to also put a link next to that.

Since I'm a bit new to this area of development, I figured I'd ask if anyone could point me in the right direction. See, not so bad. :) Thanks for your help in advance.
  • December 17, 2008
  • Like
  • 0
I have a trigger on a custom object.  If this custom object is updated any parent objects that have the custom object as a child are updated.  Everything works fine.  However, the custom object has a formula field that is date specific (i.e. if warranty end date is greater than today then "yes" else "no").  The problem is when the formula field changes to "no" (moving from 12/1 to 12/2), the trigger is not triggered; the change of the result in the formula field does not create an update.  How can I make a formula field make an update so the trigger gets used?

Thanks!


Message Edited by RedPoint on 12-02-2008 10:48 AM
I have written a simple trigger to update the ListPrice of an OpportunityLine item.  The trigger works perfectly in the sandbox and it's very simple.  I cannot deploy it because I get the following error when trying to test it: 

CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, OppLineTrigger: execution of BeforeInsert
caused by: System.NullPointerException: Attempt to de-reference a null object

Here's the trigger:
Code:
trigger OppLineTrigger on OpportunityLineItem (before insert, before update) {
  
 OpportunityLineItem[] oli = Trigger.new;
        for (OpportunityLineItem o:oli){
       Double val = [select Discount__c from Opportunity Where Id = :o.OpportunityId][0].Discount__c;
       o.Description = String.valueOf(val) + '% Discount';
       o.UnitPrice = o.ListPrice - (o.ListPrice*(val/100));
 }   
}

Here's the test class:
Code:
public class testOppLineTrigger {

 static testMethod void testOppLineTrigger() { 
     
    Product2 p = new product2(name='x', Product_Group__c = 'BNN'); 
    insert p;  
    
    Pricebook2 stdPb = [select Id from Pricebook2 where isStandard=true limit 1]; 
    
    insert new PricebookEntry(pricebook2id = stdPb.id, product2id = p.id, 
                              unitprice=10.0, isActive=true); 
     
    Pricebook2 pb = new pricebook2(name='test'); 
    insert pb; 
    PricebookEntry pbe = new PricebookEntry(pricebook2id=pb.id, product2id=p.id, 
                                            unitprice=10, isActive=true); 
    insert pbe; 
    
    Account a = new Account(name='test acct');
    insert a;    
     
    Opportunity test_o = new Opportunity(name='test', AccountId=a.id, pricebook2id=pb.id, 
                                    stageName='Open', Discount__c = 10, 
                                    CloseDate=Date.newInstance(2006,10,10)); 
    insert test_o; 
    OpportunityLineItem test_oli = new OpportunityLineItem(opportunityid=test_o.id, 
                                      pricebookentryid=pbe.id, quantity=2, TotalPrice=20); 
    insert test_oli; 
   
       Double UP = [SELECT UnitPrice FROM OpportunityLineItem WHERE Id =:test_oli.id][0].UnitPrice;

       System.assertEquals(9, UP);               
    
    }

}

 

 


Is there a way to completely clear my developer edition environment and start from scratch?

Thanks,

Chad