function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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. 

Problem:
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:pageBlockButtons>
<apex:actionFunction action="{!updateWhoWhatId}" name="updateWhoWhatIdJS" reRender="updateable">
<apex:param name="newRiskID" assignTo="{!riskID}" value=""/>
</apex:actionFunction>
<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>
<apex:pageBlockSection columns="1">
<apex:inputField style="height:100px;width:350px;" value="{!task.description}"/>
<br/><apex:outputText value="{!statusMessage}" />
</apex:pageBlockSection>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
<apex:outputPanel id="relatedList">
<apex:relatedList list="ActivityHistories"/>
</apex:outputPanel>
</apex:page>


***************************** 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') {
                updateWhoWhatIdJS(result.objectId);
            }
        }; 
        sforce.console.onFocusedSubtab(onFocusedSubtabCallback);

        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);       
                }       
            }       
        };
        sforce.console.cti.getCallObjectIds(getCallObjectIdsCallback);
                        
        var onCallBeginCallback = function (result) {
            callObjectId = result.id;
            sforce.console.cti.getCallAttachedData(result.id, getCallAttachedDataCallback);
        };
        sforce.console.cti.onCallBegin(onCallBeginCallback);

        var onCallEndCallback = function (result) {
            setCallEndDataJS(result.duration, result.disposition);
        };
        sforce.console.cti.onCallEnd(onCallEndCallback);
         
    </script>
    <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:pageBlockButtons>
            <apex:actionFunction action="{!updateWhoWhatId}" name="updateWhoWhatIdJS"reRender="updateable">
                <apex:param name="newCaseId" assignTo="{!caseId}" value=""/>
            </apex:actionFunction>              
            <apex:actionFunction action="{!setCallAttachedData}" name="setCallAttachedDataJS"reRender="updateable">
                <apex:param name="CallObject" assignTo="{!CallObject}" value=""/>
                <apex:param name="ANI" assignTo="{!ANI}" value=""/>
            </apex:actionFunction>
            <apex:actionFunction action="{!setCallEndData}" name="setCallEndDataJS"reRender="updateable, relatedList">
                <apex:param name="CallDuration" assignTo="{!CallDurationInSeconds}" value=""/>
                <apex:param name="CallDisposition" assignTo="{!CallDisposition}" value=""/>
            </apex:actionFunction>           
            <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>
                <apex:pageBlockSection columns="1">
                    <apex:inputField style="height:100px;width:350px;" value="{!task.description}"/>                                       
                    <br/><apex:outputText value="{!statusMessage}"/>                                      
                </apex:pageBlockSection>
            </apex:outputPanel>           
        </apex:pageBlock>
    </apex:form>
    <apex:outputPanel id="relatedList">
        <apex:relatedList list="OpenActivities"/>
    </apex:outputPanel>
</apex:page>   


***************************** Screen shot of my in-development custom interaction log. 
 User-added image
Ashish_SFDCAshish_SFDC
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.

https://developer.salesforce.com/forums/ForumsMain?id=906F000000096oZIAQ


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.

https://developer.salesforce.com/forums/ForumsMain?id=906F000000094PIIAY


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

method:

public pagereference save(){


      //some code here

return null;
}
https://developer.salesforce.com/forums?id=906F000000097AJIAY


Regards,
Ashish
Pradeep RajuPradeep Raju
Hi,

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 

Regards,
Pradeep
Ashish_SFDCAshish_SFDC
Hi Pradeep, 


See if the code in the below aticle helps,

https://developer.salesforce.com/page/Custom_Interaction_Logs


Regards,
Ashish