2

The following query, when run over the REST API, gives me an error:

SELECT  Id  
    WhatId,
    WhoId ,
    TaskWhoIds ,
    Subject,
    ActivityDate,
    Status, 
    Priority, 
    Owner.Name, 
    Description, 
    CreatedDate,
    CreatedBy.Name, 
    TaskSubtype, 
    PlaybookStepId__c, 
    Finish_Playbook_Step__c 
FROM    Task 
WHERE WhatId IN ('0063200001mGOA4AAO', 
        '0063200001mMfQGAA0', 
        '0063200001mfbNrAAI', 
        '0063200001lt0sWAAQ', 
        '0063200001mfayDAAQ', 
        '0063200001mfrIyAAI', 
        '0063200001meKVTAA2', 
        '0063200001lUbMTAA0', 
        '0063200001mFPNyAAO', 
        '0063200001n1go2AAA', 
        '0063200001kxB5KAAU', 
        '0063200001mg50EAAQ', 
        '0063200001mfGrKAAU', 
        '0063200001mUE8FAAW', 
        '0063200001mg8MXAAY', 
        '0063200001mGAgYAAW', 
        '0063200001mfxE8AAI', 
        '0063200001merQdAAI', 
        '0063200001mOICLAA4', 
        '0063200001mg14KAAQ', 
        '0063200001kwmoRAAQ', 
        '0063200001ml94FAAQ', 
        '0063200001mEGplAAG', 
        '0063200001mkT5lAAE', 
        '0063200001mO4SZAA0', 
        '0063200001lucmOAAQ', 
        '0063200001mf72QAAQ', 
        '0063200001n1dUdAAI', 
        '0063200001mGHaLAAW', 
        '0063200001n1gfOAAQ', 
        '0063200001n2CtIAAU', 
        '0063200001mOBhgAAG', 
        '0063200001mFfGaAAK', 
        '0063200001meQpuAAE', 
        '0063200001n1ebCAAQ', 
        '0063200001n24N4AAI', 
        '0063200001mg4YrAAI', 
        '0063200001n1VwGAAU', 
        '0063200001n1BiRAAU', 
        '0063200001n26yGAAQ', 
        '0063200001mEYy3AAG', 
        '0063200001mEHGpAAO', 
        '0063200001lutntAAA', 
        '0063200001n2B86AAE', 
        '0063200001mfBs5AAE', 
        '0063200001mfE2aAAE', 
        '0063200001mfWSUAA2', 
        '0063200001mOyAjAAK', 
        '0063200001mO4oDAAS', 
        '0063200001meH6RAAU') 
ORDER BY CreatedDate

The response from the REST endpoint is this:

[
  {
    "message": "Truncated",
    "errorCode": "MALFORMED_QUERY"
  }
]

However, the following query, which is identical except for the IDs, successfully returns the requested records.

SELECT Id,
    WhatId, 
    WhoId, 
    TaskWhoIds, 
    Subject, 
    ActivityDate, 
    Status, 
    Priority, 
    Owner.Name, 
    Description, 
    CreatedDate, 
    CreatedBy.Name, 
    TaskSubtype, 
    PlaybookStepId__c, 
    Finish_Playbook_Step__c 
FROM Task 
WHERE WhatId IN ('0063200001meDmbAAE', 
    '0063200001mfEikAAE', 
    '0063200001mfENWAA2', 
    '0063200001mf6iyAAA', 
    '0063200001mfsM7AAI', 
    '0063200001n1LinAAE', 
    '0063200001mEVMpAAO', 
    '0063200001mEYnPAAW', 
    '0063200001mfXn4AAE', 
    '0063200001mNVpYAAW', 
    '0063200001mNKdFAAW', 
    '0063200001mNMBmAAO', 
    '0063200001mUYnVAAW', 
    '0063200001mNuZdAAK', 
    '0063200001mNvuCAAS', 
    '0063200001mNmUHAA0', 
    '0063200001mNsuwAAC', 
    '0063200001mOcGjAAK', 
    '0063200001mOE7AAAW', 
    '0063200001mOTfVAAW', 
    '0063200001mOruuAAC', 
    '0063200001mOd8nAAC', 
    '0063200001mOhruAAC', 
    '0063200001mP7eoAAC', 
    '0063200001mUglmAAC', 
    '0063200001mOeTqAAK', 
    '0063200001mFxnUAAS', 
    '0063200001mfEgPAAU', 
    '0063200001mfcbNAAQ', 
    '0063200001mfa7eAAA', 
    '0063200001mfaEKAAY', 
    '0063200001meH7yAAE', 
    '0063200001mkZaAAAU', 
    '0063200001n1mOSAAY', 
    '0063200001mfedjAAA', 
    '0063200001mfoAJAAY', 
    '0063200001mfjkUAAQ', 
    '0063200001n1k5SAAQ', 
    '0063200001n1EuFAAU', 
    '0063200001mfpFQAAY', 
    '0063200001mUVHRAA4', 
    '0063200001n1EsiAAE', 
    '0063200001n1CEUAA2', 
    '0063200001mONB0AAO', 
    '0063200001mfvP7AAI', 
    '0063200001mg6xjAAA', 
    '0063200001mg8EPAAY', 
    '0063200001mg7VUAAY', 
    '0063200001mf6yIAAQ', 
    '0063200001mPCZtAAO') 
ORDER BY CreatedDate

I'm not sure how one query is "malformed" but the other is okay. I'm also not sure what the message "Truncated" means, except maybe that the result itself is too long and is truncated? But I've definitely made queries with more resulting records than this before, successfully.

(edit) Additional info: If I split up the failing query into two queries (for half the IDs each), the queries each succeed. The total records returned is something like 500.

What could be going wrong here?

  • Hi Ben - have you considered alternate approach of select id,(select id, subject etc from Tasks) from playbook where id in blah blah blah, and then iterate over the child results, rather than explicitly listing each task ? Just a thought.. – CloudHugger Jun 21 '16 at 21:20
  • I'm not listing each task, I'm listing tasks for each opportunity. These are getting a subset of the fields from the Task object, where WhatId (opportunity ID) is one of these fifty specified. There's no subquery to be done here. – Ben Dilts Jun 21 '16 at 21:24
  • @BenDilts I remember back in the day reading something about how tasks are were limited to the number of rows they could return for users without View All Data. Are you doing this query as admin? – sfdcfox Jun 21 '16 at 21:27
  • Yes, doing it as admin. – Ben Dilts Jun 21 '16 at 21:49
  • After some experimentation, it does look like I'm getting the error if my result set is over 500 records. That seems like a pretty low and arbitrary limit, considering I can use SOQL over REST to get a list of hundreds of thousands of opportunities without any problems. It just kills me to use up my API quota asking one at a time. And what happens when an opportunity has more than 500 activities on it? – Ben Dilts Jun 21 '16 at 21:52
0

My theory from running into the same problem is that this has to do with asking for the TaskWhoIds field. The theory is that asking for TaskWhoIds does a join to the TaskRelation table, and the limit ends up getting applied on the join result (the TaskRelations) rather than on the Tasks themselves. If there are many TaskWhoIds on a Task that you're asking for, the result is your 'TRUNCATED' error.

So I bet that if you remove TaskWhoIds from your SELECT, it'll return okay.

Assuming you still need the TaskWhoIds - after a lot of unsuccessful experimentation with manipulating the query itself, the only solution I could think of is to pull the Tasks and TaskRelations separately and then join them on your end.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.