Activity Forums Salesforce® Discussions moving task of subtype ListEmail from one contact to another using Salesforce apex

  • moving task of subtype ListEmail from one contact to another using Salesforce apex

    Posted by Shahzad on May 1, 2018 at 5:43 pm

    We are trying to move a task from one contact to another in a trigger. the task is created by ListEmail functionality.

    We are getting an exception if re-assigning the WhoId. Exception:

    Update failed. First exception on row 0 with id 00T1N00002TXv3jUAD; first error: FIELD_INTEGRITY_EXCEPTION, Related To ID: id value of incorrect type: 0XB1N000000XaCuWAK: [WhatId]

    This is the sample code:

    List<Task> task = [SELECT Id, RecordTypeId, WhoId, WhoCount, WhatCount, Subject, AccountId, TaskSubtype, AccountId__c, EmailListWhatID__c FROM Task where Id ='00T1N00002TXv3jUAD'];

    system.debug('task = ' + task);
    Task tk = task.get(0);
    tk.WhoId = '0031N00001UvZDpQAN';
    database.update(tk);

    shariq replied 5 years, 7 months ago 2 Members · 1 Reply
  • 1 Reply
  • shariq

    Member
    September 13, 2018 at 11:18 pm

    Hi,

    Given that the exception relates to the WhatId, I suspect that whatever the custom object type referred to by the prefix 0XB is, it does not have Allow Activities active on the object metadata.

    Hope this helps.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos