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
alivepjcalivepjc 

Create Activity in Contacts

Hi guys!

I have to create a closed (completed task) activity under the Clients tab every time an envelope is printed. I call the doUpdate() after printing. I grabbed an example from DevAngel and tried to adapt it to clients since it was originally for contracts, but doesn't work =(..

how do I link the activity to the contact?

any ideas?

doUpdate()

{

string contactId = contact.Id; // from a previous query

sforce.Task task = new sforce.Task();

task.ActivityDate = DateTime.Now;

task.ActivityDateSpecified = true;

task.Description = "Test activity";

task.Priority = "High";

task.Status = "Completed";

task.Subject = "Test activity subject";

//task.Type = "Other"; I don't have Type under the task object

//task.WhatId = contactId;   <-- I don't know if I should do this

sforce.SaveResult sr = binding.create(new sforce.sObject[] {task})[0];

}

thanks!!

chris

DevAngelDevAngel

Hi alivepjc,

I'm going to assume that Clients is actually Contacts (the tab may have been changed to Clients).  If this assumption is correct, then you may have had the type hidden from you depending on the credentials and role for the login.

If my assumption is not correct and Clients is a custom object, then maybe you don't have a Type field.  If that's the case then you can't set a value for it. 

As for the WhatId, this is the field that links the task to another object.  There is also a WhoId.  The WhatId can be the Id of a Account, Asset, Campaign, Case, Contract, Opportunity, Solution or a custom object.

The WhoId can be the Id of a Contact or Lead.

FYI, all this information is highly available via the sforce Explorer.

alivepjcalivepjc

YOU ROCK MAN!!

thank you!!!