I have issue to migrate Notes and Attachments, what's wrong?

Question:

I tried to use the following query to import attachments from the Account object:
"query": "SELECT Id, ParentId, Title, IsPrivate, Body FROM Note WHERE Parent.Type = 'Account'"

The Plugin does not insert records and shows me an 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 I am doing wrong?

Answer:

Since the ParentId is polymorphic field, you must specify the parent object.
In your case use this query:
SELECT Id, ParentId$Account, Title, IsPrivate, Body FROM Note WHERE Parent.Type = 'Account'



See also:

Polymorphic Lookup Fields.

Last updated on Sa Oct 2022