+ Start a Discussion
MGimelliMGimelli 

Refresh Service Console Tab from inline Visualforce "Save"

Hi - 

I have an inline visualforce page, which is pretty basic: 

<apex:page standardController="Account" tabStyle="Account">
    <script src="https://code.jquery.com/jquery-1.11.2.js"></script>
    <script src="https://code.jquery.com/ui/1.11.3/jquery-ui.min.js"></script>
    <script src="/support/console/29.0/integration.js" type="text/javascript"></script>
    <apex:includeScript value="/soap/ajax/32.0/connection.js"/>
    <apex:includeScript value="/soap/ajax/32.0/apex.js"/>
    <link rel="stylesheet" href="https://code.jquery.com/ui/1.11.3/themes/redmond/jquery-ui.css"/>
    <apex:form id="formID">
        <apex:pageBlock title="Add/Update Account Address" >
            <apex:pageBlockButtons location="top">
                <apex:commandButton value="Update Account Address" action="{!save}" id="inlineEditSave" onclick="RefreshPrimaryTab('{!Account.Id}')"/>
                <!-- <apex:commandLink value="Update Account Address" action="{!save}" target="_parent" styleClass="btn" style="text-decoration:none;padding:4px;"/> -->
            </apex:pageBlockButtons>
            <apex:messages />
            <apex:pageBlockSection title="Add/Update Account Address" collapsible="false">
                <apex:repeat id="fieldSetRepeat" value="{!$ObjectType.Account.FieldSets.SampleFieldSet}" 
                var="field">
                    <apex:inputField value="{!Account[field]}" required="{!field.required}"/>
                </apex:repeat>
            </apex:pageBlockSection>
        </apex:pageBlock>
        <script type="text/javascript">
            function RefreshPrimaryTab(id) 
            {    
                if(sforce.console.isInConsole()) {
                    // alert(sforce.console.isInConsole());
                    sforce.console.getFocusedPrimaryTabId(showTabId);
                } else {
                    //Standard functionality
                }
            }

            var showTabId = function showTabId(result) 
            {
                var tabId = result.id;
                alert('Primary Tab IDs: primaryTabId ' + tabId );
                sforce.console.refreshPrimaryTabById(tabId, true);
            };       

        </script>
    </apex:form>
</apex:page>


On my page, I have a fieldset to utilize a mananaged package for Address updates. The fieldset contains the Address fields on the Account object, the user enters their data and hits the "Add Update Account Address", which performs the standard "Save" action. I need to reload the page in the Service Console to show the user the updated address. Unfortuantely, the javascript I have written fires faster than the records save to the database, so it is showing as the old value. 

Any assistance is greatly appreciated. 

Thanks, 

Mikayla
 
MGimelliMGimelli
I'll put this out there in case anyone else suffers this probelm in the future. 

I simply had to change my action to "quicksave" instead of "save" and I was then able to utilize calling the javascript function on the "oncomplete" vs the "onclick" in the button.