• Jazz1610
  • NEWBIE
  • 0 Points
  • Member since 2012

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

Hi,

 

In my organisation, we have VF page to create a new record for an object. It has 2 different record types. We have overridden the New button to open the VF page. This all works fine.

Now there is a requirement to add "Save & New" button in the VF page. I have written code to save and redirect to the record type selection page (hard coded the URL).

Save works fine and redirect is also working normally. But now when i select a record type and click on create, after that an error occurs " Broken URL error".

 

My code:

public PageReference save_New(){
         try {
            sController.save();
            PageReference pr = new PageReference(<URL given here>);
            pr.setRedirect(true);
            return pr;  
       } 
       catch(Exception e) {   
            ApexPages.addMessages(e);   
            return null;        
       }

 

What am i doing wrong here?

Alternatively, Is there a standard function for Save & New that I can use?

Any help would be appreciated.

 

Regards,

Jasleen

Hi,

 

In my organisation, we have VF page to create a new record for an object. It has 2 different record types. We have overridden the New button to open the VF page. This all works fine.

Now there is a requirement to add "Save & New" button in the VF page. I have written code to save and redirect to the record type selection page (hard coded the URL).

Save works fine and redirect is also working normally. But now when i select a record type and click on create, after that an error occurs " Broken URL error".

 

My code:

public PageReference save_New(){
         try {
            sController.save();
            PageReference pr = new PageReference(<URL given here>);
            pr.setRedirect(true);
            return pr;  
       } 
       catch(Exception e) {   
            ApexPages.addMessages(e);   
            return null;        
       }

 

What am i doing wrong here?

Alternatively, Is there a standard function for Save & New that I can use?

Any help would be appreciated.

 

Regards,

Jasleen