• Frodo
  • NEWBIE
  • 0 Points
  • Member since 2009

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

Hello All,

 

I have a custom page and controller.  I am trying to do some error handling within the controller as such:

 

public PageReference sendMail2PM(){
   

string PMID = [select Deliverable_Owner__c from P4_Contract_Deliverable__c where id = :this.cd.id].Deliverable_Owner__c;

 

string PMEmail = [select email from contact where id=:PMID].email;

 

if(PMEmail==null){
    PageReference errorPage = new PageReference('https://cs1.salesforce.com/apex/errorLanding');
    errorPage.setRedirect(true);
    return errorPage;
    }

 

}

 

My problem is that when the redirect happens, somehow "inline=1" gets appended to the URL.  It seems that when the inline parameter is present then the page renders without headers or sidebars.  I want the header and sidebar so users know they are still in saleforce.

 

Where is the "inline=1" coming from and how do I get rid of it?  Or else how do I make the redirect happen with headers and sidebars?

  • February 05, 2009
  • Like
  • 0

I have a fairly simple Apex controller which I cannot figure out how to test.  I can't get above 57% code coverage.  I am not understanding something. Can someone please shed light. I do not have coverage for lines 15,16,17,18,19,20,21,23 Here is the code:

 

public class copyAddress {

 

P4_AssetDeploymentRelationship__c currentDeploy;

 

public copyAddress(ApexPages.StandardController controller) {
        this.currentDeploy = (P4_AssetDeploymentRelationship__c)controller.getRecord();
}

 

public PageReference address()
    {
        if (System.currentPageReference().getParameters().get('id')== null) {
        PageReference redraw = Apexpages.currentPage();
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Parameter Does Not Exist'));
      return redraw; }
      string contactID = [select contact__c from P4_AssetDeploymentRelationship__c where id = :currentDeploy.Id].contact__c;     
      this.currentDeploy.Shipment_St_Address_1__c = [select mailingstreet from contact where id = :ContactID].mailingstreet;
      currentDeploy.Shipment_City__c = [select mailingcity from contact where id = :ContactID].mailingcity;
      currentDeploy.Shipment_State_Province__c = [select mailingstate from contact where id = :ContactID].mailingstate;
      currentDeploy.Shipment_Country__c = [select mailingcountry from contact where id = :ContactID].mailingcountry;
      currentDeploy.Shipment_Postal_Code__c  = [select mailingpostalcode from contact where id = :ContactID].mailingpostalcode;
      upsert currentDeploy;
      return null;
    }
 
    public PageReference persistAddress()
    {
       upsert currentDeploy;
       return null;
    }
    public static testMethod void testCopyAddress() {
    P4_AssetDeploymentRelationShip__c testDeploy = new P4_AssetDeploymentRelationShip__c();
    insert testDeploy;
    ApexPages.StandardController sc = new ApexPages.standardController(testDeploy);
    copyAddress testAddress = new copyAddress(sc);
    PageReference testPage = testAddress.Address();
    System.Assert(testPage != null);
    testPage = testAddress.persistAddress();
    System.AssertEquals(null,testPage);
    P4_AssetDeploymentRelationShip__c x;
    Contact c = new contact(FirstName='James',LastName='Malone',MailingStreet='8102 Dewberry Circle');
     insert c;
    testAddress.currentDeploy = new P4_AssetDeploymentRelationShip__c(contact__c=c.Id);
  
    insert testAddress.currentDeploy;   
       string contactID = [select contact__c from P4_AssetDeploymentRelationship__c where id = :testAddress.currentDeploy.Id].contact__c;     
       System.AssertEquals(testAddress.currentDeploy.contact__c, contactID);
     testAddress.currentDeploy.Shipment_St_Address_1__c = [select mailingstreet from contact where id = :ContactID].mailingstreet;
     upsert testAddress.currentDeploy;
     System.AssertEquals(c.MailingStreet,testAddress.currentDeploy.Shipment_St_Address_1__c);
     testAddress.currentDeploy.Shipment_State_Province__c = [select mailingstate from contact where id = :ContactID].mailingstate;
     upsert testAddress.currentDeploy;
      System.AssertEquals(c.MailingState,testAddress.currentDeploy.Shipment_State_Province__c);
}
}

 

 

  • January 30, 2009
  • Like
  • 0

Hello All,

 

I have a custom page and controller.  I am trying to do some error handling within the controller as such:

 

public PageReference sendMail2PM(){
   

string PMID = [select Deliverable_Owner__c from P4_Contract_Deliverable__c where id = :this.cd.id].Deliverable_Owner__c;

 

string PMEmail = [select email from contact where id=:PMID].email;

 

if(PMEmail==null){
    PageReference errorPage = new PageReference('https://cs1.salesforce.com/apex/errorLanding');
    errorPage.setRedirect(true);
    return errorPage;
    }

 

}

 

My problem is that when the redirect happens, somehow "inline=1" gets appended to the URL.  It seems that when the inline parameter is present then the page renders without headers or sidebars.  I want the header and sidebar so users know they are still in saleforce.

 

Where is the "inline=1" coming from and how do I get rid of it?  Or else how do I make the redirect happen with headers and sidebars?

  • February 05, 2009
  • Like
  • 0
Hello, There must be a simple solution, bit somehow I can't get it. To check validity on a dutch bank account (text string) I need to extract al the chars in the account and do some sort of formula on it. How do I extract say the 3rd char. from a string. Now I use VALUE(RIGHT(LEFT(String__c,3),1)). Get all char upto 3rd form the start of a text string and than get the 1st char from the end. Than with Value I change it to a number. In this case the formula gets to long ( I need to do this 9 times and than add other logic) Anybody have an idea how to extract a char from a string in a different way? Thanks Jeroen
  • February 05, 2009
  • Like
  • 0

Hi,

 

We have an email messaging class Messaging.SingleEmailMessage for sending custom emailsWe need to configure the From email Address,and we are not able to find any such property that we can set the "From" address in Messaging.SingleEmailMessage object.

 

 

Kindly provide the solution as soon as possible!!

 

Thanks.

I have a fairly simple Apex controller which I cannot figure out how to test.  I can't get above 57% code coverage.  I am not understanding something. Can someone please shed light. I do not have coverage for lines 15,16,17,18,19,20,21,23 Here is the code:

 

public class copyAddress {

 

P4_AssetDeploymentRelationship__c currentDeploy;

 

public copyAddress(ApexPages.StandardController controller) {
        this.currentDeploy = (P4_AssetDeploymentRelationship__c)controller.getRecord();
}

 

public PageReference address()
    {
        if (System.currentPageReference().getParameters().get('id')== null) {
        PageReference redraw = Apexpages.currentPage();
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Parameter Does Not Exist'));
      return redraw; }
      string contactID = [select contact__c from P4_AssetDeploymentRelationship__c where id = :currentDeploy.Id].contact__c;     
      this.currentDeploy.Shipment_St_Address_1__c = [select mailingstreet from contact where id = :ContactID].mailingstreet;
      currentDeploy.Shipment_City__c = [select mailingcity from contact where id = :ContactID].mailingcity;
      currentDeploy.Shipment_State_Province__c = [select mailingstate from contact where id = :ContactID].mailingstate;
      currentDeploy.Shipment_Country__c = [select mailingcountry from contact where id = :ContactID].mailingcountry;
      currentDeploy.Shipment_Postal_Code__c  = [select mailingpostalcode from contact where id = :ContactID].mailingpostalcode;
      upsert currentDeploy;
      return null;
    }
 
    public PageReference persistAddress()
    {
       upsert currentDeploy;
       return null;
    }
    public static testMethod void testCopyAddress() {
    P4_AssetDeploymentRelationShip__c testDeploy = new P4_AssetDeploymentRelationShip__c();
    insert testDeploy;
    ApexPages.StandardController sc = new ApexPages.standardController(testDeploy);
    copyAddress testAddress = new copyAddress(sc);
    PageReference testPage = testAddress.Address();
    System.Assert(testPage != null);
    testPage = testAddress.persistAddress();
    System.AssertEquals(null,testPage);
    P4_AssetDeploymentRelationShip__c x;
    Contact c = new contact(FirstName='James',LastName='Malone',MailingStreet='8102 Dewberry Circle');
     insert c;
    testAddress.currentDeploy = new P4_AssetDeploymentRelationShip__c(contact__c=c.Id);
  
    insert testAddress.currentDeploy;   
       string contactID = [select contact__c from P4_AssetDeploymentRelationship__c where id = :testAddress.currentDeploy.Id].contact__c;     
       System.AssertEquals(testAddress.currentDeploy.contact__c, contactID);
     testAddress.currentDeploy.Shipment_St_Address_1__c = [select mailingstreet from contact where id = :ContactID].mailingstreet;
     upsert testAddress.currentDeploy;
     System.AssertEquals(c.MailingStreet,testAddress.currentDeploy.Shipment_St_Address_1__c);
     testAddress.currentDeploy.Shipment_State_Province__c = [select mailingstate from contact where id = :ContactID].mailingstate;
     upsert testAddress.currentDeploy;
      System.AssertEquals(c.MailingState,testAddress.currentDeploy.Shipment_State_Province__c);
}
}

 

 

  • January 30, 2009
  • Like
  • 0