You need to sign in to do that
Don't have an account?

Save not returning to View Page
Hi
The Save button n my VF Form is not returning to the VIew Page so it is not obviouse that the record has saved. This is the controller code
public PageReference save(){
try{
upsert editItem;
system.debug(BusUnits.keyset());
for(String key:BusUnits.keyset()){
if(BusUnits.get(key) == true){
tempMarketItem = MarketItems.get(key);
system.debug(tempMarketItem);
if(tempMarketItem.Items__c == null){
tempMarketItem.Items__c = editItem.id;
}
tempMarketItem.Business_Unit__c = key;
system.debug(tempMarketItem);
MarketItems.put(key, tempMarketItem);
upsert MarketItems.get(key);
for(integer i : numberOfDates.get(key)){
if((i < numberOfDates.get(key).size()) && (effectiveDates.get(key).get(i).Effective_Date__c != null)){
tempED = new Effective_Date__c();
tempED = effectiveDates.get(key).get(i);
if(tempED.Market_Item__c == null){
tempED.Market_Item__c = MarketItems.get(key).Id;
}
effectiveDates.get(key).put(i, tempED);
upsert effectiveDates.get(key).get(i);
}
}
}
system.debug('BusUnitsOld' +BusUnitsOld);
system.debug('BusUnits' +BusUnits);
if((MarketItems.get(key).Business_Unit__c == key) && (BusUnits.get(key) == false)){
delete MarketItems.get(key);
}
}
PageReference home = new PageReference('/'+editItem.id);
home.setRedirect(true);
return home;
}
catch (Exception ex){
ApexPages.addMessages(ex);
system.debug(ex);
return null;
}
}
And teh Form code
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save" id="theButton"/>
</apex:pageBlockButtons>
The Save button n my VF Form is not returning to the VIew Page so it is not obviouse that the record has saved. This is the controller code
public PageReference save(){
try{
upsert editItem;
system.debug(BusUnits.keyset());
for(String key:BusUnits.keyset()){
if(BusUnits.get(key) == true){
tempMarketItem = MarketItems.get(key);
system.debug(tempMarketItem);
if(tempMarketItem.Items__c == null){
tempMarketItem.Items__c = editItem.id;
}
tempMarketItem.Business_Unit__c = key;
system.debug(tempMarketItem);
MarketItems.put(key, tempMarketItem);
upsert MarketItems.get(key);
for(integer i : numberOfDates.get(key)){
if((i < numberOfDates.get(key).size()) && (effectiveDates.get(key).get(i).Effective_Date__c != null)){
tempED = new Effective_Date__c();
tempED = effectiveDates.get(key).get(i);
if(tempED.Market_Item__c == null){
tempED.Market_Item__c = MarketItems.get(key).Id;
}
effectiveDates.get(key).put(i, tempED);
upsert effectiveDates.get(key).get(i);
}
}
}
system.debug('BusUnitsOld' +BusUnitsOld);
system.debug('BusUnits' +BusUnits);
if((MarketItems.get(key).Business_Unit__c == key) && (BusUnits.get(key) == false)){
delete MarketItems.get(key);
}
}
PageReference home = new PageReference('/'+editItem.id);
home.setRedirect(true);
return home;
}
catch (Exception ex){
ApexPages.addMessages(ex);
system.debug(ex);
return null;
}
}
And teh Form code
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save" id="theButton"/>
</apex:pageBlockButtons>
return new ApexPages.StandardController(editItem).view();
Sorry!! did not understand. Could you please post the error?
Also, please see if using "ID" in caps resolve the issue(in your old code.)