Skip to content

Polymorphic Lookup Fields with FieldMapping to different Target Object #1110

@Libertha

Description

@Libertha

I am trying to migrate Activities (read Task, Event and EmailMessage) from 1 org to another org.

In the Source org, Contract object is used (standard) in the target org, Contract__c (custom object) is used.

Task & Event Contain a polymorphic field (WhatId) so i need to use the $ selector, however the following error occurs:

{Event} Fetching the Target data from Org (STAGE 2: filtered records) ...
[ERROR] Error during execution of the command: No such column 'OldOrgId__c' on entity 'Contract'. 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..

It seems it is trying to get the OldOrgId from Contract in target, while it should look at "Contract__c".

How can i map the polymorphic field to a different object in the target compared to the source? As i also with the Contract mapping

i have tried adding field mapping to Event like (with use fieldmapping set to true):
{
"targetObject": "Event"
},
{
"sourceField": "WhatId$Contract",
"targetField": "WhatId$Contract__c"
}

sadly this didnt succeed either.

Below my export.json

{
"promptOnMissingParentObjects": false,
"bulkApiVersion": "2.0",
"objects": [
{
"query": "SELECT Id, OldOrgId__c FROM Contact WHERE OldOrgRecordType__c = '012P900000082kbIAA' ",
"operation": "Readonly",
"externalId": "OldOrgId__c"
},
{
"query": "SELECT Id, OldOrgId__c FROM Contract",
"operation": "Readonly",
"externalId": "OldOrgId__c",
"useFieldMapping": true,
"fieldMapping": [
{
"targetObject": "Contract__c"
}
]
},
{
"query": "SELECT Id, WhoId$Contact, WhatId$Contract, Subject, Location, IsAllDayEvent, ActivityDateTime, ActivityDate, DurationInMinutes, StartDateTime, EndDateTime, EndDate, Description, AccountId, OwnerId, Type, ShowAs, IsGroupEvent, GroupEventType, CreatedDate, CreatedById, ReminderDateTime, IsReminderSet, EventSubtype, OldOrgId__c FROM Event WHERE OldOrgId__c != null AND WhatId != null",
"useQueryAll": true,
"operation": "Upsert",
"externalId": "OldOrgId__c",
"useValuesMapping": true,
"master": false
},
{
"query": "SELECT Id, WhoId$Contact, WhatId$Contract, Subject, ActivityDate, CompletedDateTime, Status, Priority, IsHighPriority, OwnerId, Description, Type, AccountId, IsClosed, CreatedDate, LastModifiedDate, CallDurationInSeconds, CallType, CallDisposition, CallObject, ReminderDateTime, IsReminderSet, TaskSubtype, CompletedDateTime, OldOrgId__c FROM Task WHERE OldOrgId__c != null AND (TaskSubtype != 'Email' OR Old_Email_Task__c = TRUE) AND WhatId != null",
"useQueryAll": true,
"operation": "Upsert",
"externalId": "OldOrgId__c",
"useValuesMapping": true,
"master": false
},
{
"query": "SELECT Id, RelatedToId$Contract, CreatedById, CreatedDate, LastModifiedDate, TextBody, HtmlBody, Headers, Subject, Name, FromName, FromAddress, ToAddress, CcAddress, BccAddress, Incoming, HasAttachment, Status, MessageDate, MessageIdentifier, ThreadIdentifier, ClientThreadIdentifier, IsClientManaged, IsTracked, IsOpened, FirstOpenedDate, LastOpenedDate, IsBounced, OldOrgId__c FROM EmailMessage WHERE RelatedToId != null",
"useQueryAll": true,
"operation": "Upsert",
"externalId": "OldOrgId__c",
"useValuesMapping": true,
"master": false
}
]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions