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 

insert task to account

Hello,
Apologies for this basic question. This is my first interaction with Salesforce in general and Visualforce coding in particular...
I'm using Javascript on Visualforce page.
I need to insert few data items (all are strings) as Task on a given account. I've already obtained the account ID and my Calback function received the relevant strings to insert (i.e. no trigger or query is required).
How do I insert this information as Task for this user using Javascript code?
Note (just in case this info is relevant) that this is a click-to-dial implementation which shows the Phone button on all type of screens where phone number exists therefore it is not bound to any specific controller. 
Let me know if you require any further information from my side.
Thank you for any support
Harel
Best Answer chosen by Harel Cohen
Prithviraj_ChavanPrithviraj_Chavan
Hi Harel Cohen,
plesae follow the link
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_remote_objects_using_create.htm

All Answers

Prithviraj_ChavanPrithviraj_Chavan
Hi Harel Cohen,
plesae follow the link
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_remote_objects_using_create.htm
This was selected as the best answer
Harel CohenHarel Cohen
Hi Prithviraj_Chavan,
Thank you for your reply.
Indeed I've gone through that whole manual but I didn't figure out that this was the relevant section for my question...
Just to verify the process. If I want to insert a Call Log to the person (account) I have just spoken with I need to do this:
  1. I Create Remote Object as Task:
    <apex:remoteObjects jsNamespace="CallLog">
    	    <apex:remoteObjectModel name="Task" fields="AccountId, CallObject, Description, ActivityDate"/>
    </apex:remoteObjects>
  2. Instantiate:
    var ct = new CallLog.Task(
    {
       AccountId: "000234....Cix",
       CallObject: "785899AF65884C5B",
       Description: "Sales Call",
       ActivityDate: "01/03/2017",
    });
Is this correct?
Thank you
Harel