0

I'm having an inline visualforce page (to load a map) within a section of page layout. My requirement is to update a field in the same record once the page is loaded. I have the inline VF page and the standard controller. I had an action function on Apex page to update the value. It works perfectly, but it doesn't display the updated value in the layout. It has to be refreshed to load the value. I tried to use an ActionFunction within Apex:Form. But looks like it doesn't trigger the Action method (No debug). Here's the code

<apex:actionFunction name="updateDistance" action="{!updateRec}" rerender="mainMap" status="myStatus">

and my actionmethod is,

public PageReference updateRec(){
    try{        
        system.debug('sId::'+sId);
        if (sId != NULL && sId != ''){
            custom__c Rec = new custom__c(Id=sId);            
            Rec.field__c = value;

            upsert Rec;                

        }    
    }catch(DMLException dme){
        system.debug('Exception dme:::'+dme.getMessage());
        return null;            
    }

    return null;
}

Anyone can suggest a workaround for this?

  • 1
    can you add your vf page code? – Safiya PV Apr 26 '17 at 6:24
0

I think you need to refresh the page the to see the update.

From <apex:actionFunction> use oncomplete event to refresh the page as follows:

<apex:actionFunction 
name="updateDistance" 
action="{!updateRec}" 
oncomplete = "window.top.location.reload();"
rerender="mainMap" 
status="myStatus">
  • My issue is it doesnt call the controller method from action function, even though I manually refreshes the page. No debug logs. – L Mudiyanse Apr 26 '17 at 6:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.