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
DG-AngelDG-Angel 

Task Update Issue

Hi
 
I am trying to update the task using the API .
 
I am creating the fields like this
$createFields = array (
  'ActivityDate' =>$Task_date,
        'Priority' =>'Normal',
        'Status' => 'Not Started',
        'Description' => $_POST['task_logacall'],
        'Subject' => $_POST['task_subject'],
        'WhatID' => $_POST['policy_id'],
  'OwnerId' => $_SESSION['Id']
 
Now its creating the new task but when I add the user Id in lastModifiedID its not creating the task and also not throwing any error, The code is
 
$createFields = array (
  'ActivityDate' =>$Task_date,
        'Priority' =>'Normal',
        'Status' => 'Not Started',
        'Description' => $_POST['task_logacall'],
        'Subject' => $_POST['task_subject'],
        'WhatID' => $_POST['policy_id'],
  'OwnerId' => $_SESSION['Id'],
LastModifiedById=> $_SESSION['Id']
 
$task_result = $ssuUtility->createTask($createFields);
 
The createTask Functions looks like this
 
public function  createTask($fields) {
 
    $contactSObject = new SObject();
    $contactSObject->type = 'Task';
    $contactSObject->fields = $fields;
    $createContactResult = $this->mySforceConnection->create(array($contactSObject));
    return $createContactResult;
  }
 
the $_SESSION['Id'] i am getting by querying the User__c object. Its updating the owner Id but not the lastmodifiedId, which changes the name of the person who last modified it.
 
Please let me know what is going wrong here. Or is that I cannot change the LastModified Person name by updating LastModifiedById using Session_Id from user__c object
 
DG
SuperfellSuperfell
You can't change LastModifiedById, its implicitly set based on the sessionId that made the update call. I think you'll find if you examine the results structure that in the case where you try and change LastModifiedById, the result will indicate that there was a failure.
DG-AngelDG-Angel
The thing is , it does not show me any error or may be I can't see the error. But it doesnt create a task.
 
Is there any other way to change the LastModifiedByid??
 
in this function
 public function  createTask($fields) {
 
    $contactSObject = new SObject();
    $contactSObject->type = 'Task';
 $contactSObject->LastModifiedById = '005300...';
    $contactSObject->fields = $fields;
    $createContactResult = $this->mySforceConnection->create(array($contactSObject));
    return $createContactResult;
  }
 
I tried putting  $contactSObject->LastModifiedById = '005300...; but it didnt work.
 
When i am querying the user__c object i am getting the session Id. and thats wat i am using for owner Id.
 
Any other way I can change the LastModifiedById?
 
DG
SuperfellSuperfell
$createContactResult will contain the result of the call success/fail/error message.

You can't change the lastModifiedId, its a read-only field that's managed by the system.
dhruvadhruva
Two thoughts come to mind:
1. If that ID is your own ID (or strictly, the ID of the API login), then don't do anything.  sfdc will automatically assign that ID.

2. If that ID is not the API login, then saying it is the last modifier would be incorrect, no?

DG-AngelDG-Angel

Its the API one. SFDC does assign it automatically. But the logic of application requires me to update that also.

The person loggin into salesforce is administrator and it allows other people to login and create tasks. so everytime we see the administrator as the last modified person. But I need the last modified person name to be the other one.

 

All this is happening through phone. Thats the reason we are using administrator login.

Park Walker (TAGL)Park Walker (TAGL)
Is there a perticular reason that you need to use the LastModified Id  field, or could you add a custom field that you can can populate with the Id of the person actually making the update? Another option if you are tracking comments is to prefix the comment string with "On 7/5/2007 Some Name said:".