function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
BDArnzBDArnz 

retURL woes!

I'm having trouble returning back to the correct page using the retURL parameter.  Here's the function from a customer controller extension that is triggered from a button on a VF page.
 
Code:
 public pagereference createInstall(){
  Service__c tempService = new Service__c();
  tempService.Account__c = this.myAsset.AccountId;
  tempService.Contact_1__c = this.myAsset.ContactId;
  tempService.Description__c = 'INST SO '+this.myAsset.Sales_Order__c;
  tempService.Classification__c = 'New Installation';
  tempService.RecordTypeId = '01230000000DMrlAAG';
  tempService.Start_Date__c = this.myAsset.Target_Ship__c+14;
  tempService.SO__c = this.myAsset.Sales_Order__c;
  tempService.PO__c = this.myAsset.Purchase_Order__c;
  tempService.Quote__c = this.myAsset.Quote__c;
  tempService.Stage__c = 'Not Shipped';
  insert tempService;
  
  
  Link__c tempLink = new Link__c();
  tempLink.Asset__c = this.myAsset.Id;
  tempLink.Service__c = tempService.Id;
  insert tempLink;
  
  PageReference editService = new PageReference('/'+tempService.Id+'/e?retUrl=https://cs2.salesforce.com/'+this.myAsset.Id);
  editService.setRedirect(true);
  return editService;
  
 }

 
This 1st chunk creates a new Service Record (custom object).  The second chunk inserts a record linking the new service to an Asset.  The final 3 lines call up the service edit page so the user can review the new record.  After saving (or cancelling) I would like the user to be returned back to the asset detail page.
 
Passing the retURL should take the user back to the Asset detail page (which is where this code is triggered from).  This is the only part of the code that fails.  The service record gets created just fine, the link gets created just fine, the Service Edit screen opens just fine but when the user clicks 'Save' on that screen they are returned to the SF home page instead of the asset detail screen.
 
I have tried both methods of including the full server address (https://cs2.salesforce.com/recordId) and also the partial method (/recordId).  Both methods return the user to the home page.
 
Anyone know what I'm doing wrong?
Best Answer chosen by Admin (Salesforce Developers) 
GuyClairboisGuyClairbois

Hi there,

I'm having the same problem today. Did you find a solution in the mean while?

Many thanks,

Guy

 

*** EDIT: found the solution! Just replacing retUrl by retURL did the job..... ***