Notes and attachments migration issues.


Question:

I attempted to import attachments from the Account object using this query:

SELECT Id, ParentId, Title, IsPrivate, Body FROM Note WHERE Parent.Type = 'Account'

However, the Plugin failed to insert records and displayed this error:

[ERROR] Error during execution of the command: 
Name, ParentId, CreatedBy.Name, Parent.Name FROM Attachment
                                ^
ERROR at Row:1:Column:136
No such column 'Name' on entity 'Name'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.
Execution of the command sfdmu:run has been finished. Exit code 4 (COMMAND_EXECUTION_ERROR).

What am I doing wrong?


Answer:

The error occurs because the ParentId is a polymorphic field. You must specify the parent object type in your query. Here’s the corrected version:

SELECT Id, ParentId$Account, Title, IsPrivate, Body FROM Note WHERE Parent.Type = 'Account'

See also: Polymorphic Lookup Fields

Last updated on 20th Apr 2024