+ Start a Discussion
avimeiravimeir 

How to maintain URL state?

Hi,

 

I have a controller InvoiceController that does two things:

 

1. initInvoice finds an object of type Invoice__c and stores it in InvoiceController.inv which is defined as 

public static Invoice__c inv {set; get;}

 

 

2. saveInvoice updates the Invoice__c object that we fetched in initInvoice. saveInoice is called when a user clicks a button on the VF page.

 

 

My question is - is there a way to keep the object somewhere between calls? When saveInvoice gets called, the  InvoiceController.inv is null , and I'd like it to be what we've loaded in initInvoice

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox

Don't make it static. Static variables are also transient, which means they are not stored in the view state.