+ Start a Discussion
Megan MoodyMegan Moody 

custom interaction log saving functionality

I am doing development in the Service Cloud Service Console. I discovered that our needed functionality isn't there in the service console configurability, so I moved on to creating my own custom console. I used the sample code from this post (http://wiki.developerforce.com/page/Custom_Interaction_Logs) on wiki.developerforce which I was pointed to via this blog post (http://blogs.salesforce.com/product/2012/02/custominteractionlog.html)in blogs.salesforce.com. That code uses the Task, Case, and Contact objects. Rather than Case, I need to use a custom object (Risk__c). 

And here I should note that I'm totally new to Visualforce and Apex coding, so please forgive any simple questions/confusions on my part. 

The Save and Save New buttons on the log are not saving

Pertinent Information:
  • They should save the information in the Log screen to the Activity History of my custom object, Risk.
  • I am 99% sure that the code linking the Log to my Contact is working properly.
  • No errors are generated when I click either the Save or Save New buttons.
  • When I click Save, the only thing that happens is the "Last Save" date time shows at the bottom of the screen.
  • When I click Save New, any information I entered in the fields manually is cleared (presumably to allow me to enter a new record. Duh, I know). 

***************************** Visual Force Code - my edited version *****************************

<apex:page standardController="Risk__c" extensions="CustomInteractionLog" tabStyle="Task">
<apex:includeScript value="/support/console/24.0/integration.js"/>

<apex:form >
<apex:pageBlock title="Log A Call" id="thePageBlock" mode="edit">
<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}" reRender="updateable, relatedList"/>
<apex:commandButton value="Save And New" action="{!saveAndNew}" reRender="updateable, relatedList"/>
<apex:actionFunction action="{!updateWhoWhatId}" name="updateWhoWhatIdJS" reRender="updateable">
<apex:param name="newRiskID" assignTo="{!riskID}" value=""/>
<apex:outputPanel id="updateable">
<apex:pageBlockSection columns="1">
<apex:inputField value="{!task.whoId}"/>
<apex:inputField style="width:230px;" value="{!task.subject}"/>
<apex:inputField style="width:230px;" value="{!task.Category__c}"/>
<!-- <apex:inputField value="{!task.ANI__c}"/> -->
<apex:pageBlockSection columns="1">
<apex:inputField style="height:100px;width:350px;" value="{!task.description}"/>
<br/><apex:outputText value="{!statusMessage}" />
<apex:outputPanel id="relatedList">
<apex:relatedList list="ActivityHistories"/>

***************************** Visual Force Code - the version I copied from wiki.developer (http://wiki.developerforce.com/page/Custom_Interaction_Logs) *****************************

<apex:page standardController="Case" extensions="CustomInteractionLog" tabStyle="Task">   
    <apex:includeScript value="/support/console/24.0/integration.js"/>
    <script type="text/javascript">
        var callObjectId = null;
        var onFocusedSubtabCallback = function (result) {
            var entityId = result.objectId;
            if (entityId.substr(0,3) === '500') {

        var getCallAttachedDataCallback = function (result) {           
            setCallAttachedDataJS(callObjectId, JSON.parse(result.data).ANI);
        /* Retrieving call id of first call that came in and
        * calling getCallAttachedData() to retrieve call data.
        * Note that we are using the cti submodule here
        var getCallObjectIdsCallback = function (result) {       
            if (result.ids !== 'null') {      
                var ids = result.ids.split(',');       
                if (ids.length > 0) {  
                    callObjectId = ids[0];    
                    sforce.console.cti.getCallAttachedData(callObjectId, getCallAttachedDataCallback);       
        var onCallBeginCallback = function (result) {
            callObjectId = result.id;
            sforce.console.cti.getCallAttachedData(result.id, getCallAttachedDataCallback);

        var onCallEndCallback = function (result) {
            setCallEndDataJS(result.duration, result.disposition);
    <apex:form >
        <apex:pageBlock title="Log A Call" id="thePageBlock" mode="edit">
            <apex:pageMessages />
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}" reRender="updateable, relatedList"/>
                <apex:commandButton value="Save And New" action="{!saveAndNew}"reRender="updateable, relatedList"/>
            <apex:actionFunction action="{!updateWhoWhatId}" name="updateWhoWhatIdJS"reRender="updateable">
                <apex:param name="newCaseId" assignTo="{!caseId}" value=""/>
            <apex:actionFunction action="{!setCallAttachedData}" name="setCallAttachedDataJS"reRender="updateable">
                <apex:param name="CallObject" assignTo="{!CallObject}" value=""/>
                <apex:param name="ANI" assignTo="{!ANI}" value=""/>
            <apex:actionFunction action="{!setCallEndData}" name="setCallEndDataJS"reRender="updateable, relatedList">
                <apex:param name="CallDuration" assignTo="{!CallDurationInSeconds}" value=""/>
                <apex:param name="CallDisposition" assignTo="{!CallDisposition}" value=""/>
            <apex:outputPanel id="updateable">
                 <apex:pageBlockSection columns="1">
                    <apex:inputField value="{!task.whoId}"/>                       
                    <apex:inputField value="{!task.whatId}"/>
                    <apex:inputField style="width:230px;" value="{!task.subject}"/>                   
                    <!-- <apex:inputField value="{!task.ANI__c}"/> -->                   
                <apex:pageBlockSection columns="1">
                    <apex:inputField style="height:100px;width:350px;" value="{!task.description}"/>                                       
                    <br/><apex:outputText value="{!statusMessage}"/>                                      
    <apex:outputPanel id="relatedList">
        <apex:relatedList list="OpenActivities"/>

***************************** Screen shot of my in-development custom interaction log. 
 User-added image
Hi Megan, 

See the discussions and the suggessions in the links below, 

This is because you are using the standard controller save, which redirects you to the record view page for the object in question.  This means that you get a standard salesforce page embedded in an iframe within your standard visualforce page.


There might be a conflict between your action methods and the same methods in the standard controller, which has save() and cancel() methods.  Your methods might not be getting called if the standard controller methods take priority.  Try renaming your action methods to something unique (e.g. saveAction(), cancelAction()) and see if you get different behavior.


<apex:commandbutton action="{!save}" value = "save"/>


public pagereference save(){

      //some code here

return null;

Pradeep RajuPradeep Raju

Can u plz suggest how to fetch id of custom interaction log so that on click of save on case edit page i can associate these 2 objects standard Case & custom interaction via a Junction object 

Hi Pradeep, 

See if the code in the below aticle helps,