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
Harel CohenHarel Cohen 

Can't find mt Task

Hello,
I'm trying to insert a call log (Task) to an account from Visualforce using Javascript. The thing is that when I go to that acount the Task is not there.
This is what I have done so far:
  1. Declared the object (from the Apex part):
    <apex:remoteObjects jsNamespace="CallLog"> 
        <apex:remoteObjectModel name="Task" fields="AccountId, CallObject, Description, ActivityDate"/>
    </apex:remoteObjects>
    
  2. Instantiate it:
    var oTaskCL = new CallLog.Task();
  3. Populated some values including the binding to Account ID:
    oTaskCL.Set('AccountId', accId);
    oTaskCL.Set('Description', 'Sales Call');
    oTaskCL.Set('ActivityDate', '01/03/2017');
  4. I've verified that accId is the correct account ID at this stage by doing screen-pop to the account using accId just before this action.
However when I go to the UI of the account I don't see this (or any other) records.
Any ideas where did this task went to or what am I doing wrong?
Thanks in advance,
Harel

 
Amit Singh 1Amit Singh 1
Harel,

May I suggest you to check the debug log and you will get the details of the execution also details of any errors/exceptions if any.

Also, make sure that you have added Task as related list of Account layout.

Let me know if this helps :)

Thanks!
Amit Singh
Alex EzhilarasanAlex Ezhilarasan
I think you are checking in Open Activities. The call log appears as a completed task under Activity History.
Harel CohenHarel Cohen
Hi Amit & Alex,
Thank you for taking the time to answer.
Amit: "Debug log" as in the client's browser? There is nothing there... If you meant for something else please advise...
Amit & Alex: How do I "make sure that you have added Task as related list of Account layout"? In the UI I see 'Open Activities' and 'Activity History'. Does this mean that it is related list?

This is my complete Visualforce test code. Please see if you can figure out why I can't get the task into account 0016E00000AWcXOQA1
The screenPop() is there to open the acount immediately to check if the task record is in there.
<apex:page showHeader="false"> 
<apex:includeScript value="/soap/ajax/39.0/connection.js"/>
<apex:includeScript value="/support/api/39.0/interaction.js"/>
<apex:remoteObjects jsNamespace="CallLog"> 
    <apex:remoteObjectModel name="Task" fields="AccountId, CallObject, Description, ActivityDate, OwnerId"/>
</apex:remoteObjects>
<style>
    body {background-color:white;}
</style> 
<script type="text/javascript">
    var oTaskCL = new CallLog.Task({
        Description: "Sales Call",
        ActivityDate: "01/03/2017",
        AccountId: "0016E00000AWcXOQA1",
        OwnerId: "0016E00000AWcXOQA1"
        });
    oTaskCL.create();
    sforce.interaction.screenPop("0016E00000AWcXOQA1", true, screenPopCallback);

    var screenPopCallback = function (response){
        if (response.result) {
            consol.log("mclog::Screen pop was set successfully.");
        } else {
            consol.log("mclog::Screen pop failed. Error: " + result.error);
        }
    };
</script>
</apex:page>