I have a controller which creates a record (and consequently an ID). After the record is created, variables are set. However, when I attempt to access the variable after the controller action has run, it's not getting the updated values.
After I run the {!save} method the record is created BUT the controller reference variable is not updated. How can I get at that new ID value?
Javascript/VF
<apex:commandButton value="navigate to record" onclick="navigateToActivity(); return false;"/>
<script>
function navigateToActivity()
{
var controllerValues = '{!recordID} {!geoLat}'
alert(controllerValues);
}
</script>
Controller
public Activity__C act {get; set;}
public User owner {get; set;}
public boolean hasLocation {get; set;}
public double geoLat {get; set;}
public double geoLong {get; set;}
public string recordID {get; set;}
public QuickCreateActivityController(){
act = new Activity__c();
owner = new user();
hasLocation = false;
geoLat = 0.0;
geoLong = 0.0;
recordId = string.valueof(act.id);
}
public void save() {
system.debug(hasLocation);
system.debug(string.valueof(geoLat));
system.debug(string.valueof(geoLong));
system.debug('pre insert id' + recordId);
/**************ID is blank********/
checkForWorkday();
insert act;
recordID = string.valueof(act.Id);
system.debug('post insert id' + recordId);
/**************ID is Created********/
}