This is a follow-up to my previous question where I asked for help importing data for lookup fields: How do lookup relationships work with force:data:tree:export? Don't know where to start
I can now successfully import records containing lookup fields, but only in certain situations. I am encountering a very strange error, so bear with me as this is a little hard to explain.
My goal: to import a Lead object that contains a lookup field to my custom object Employee__c.
The issue: when I try to import the lead (using the JSON syntax explained in the question linked above) I get the error "id value of incorrect type: @EmpRef1".
However, there is one situation where I was able to get the lead to import successfully: I created a second field on Lead that matches my existing Employee lookup field. So I have two different lookup fields on Lead that are exactly the same. When I try to populate BOTH of the lookup fields with @EmpRef1, then the import happens successfully for both fields. So my employee1 field ONLY accepts input when there's another employee2 lookup that is given the same input. Do you guys have any ideas why this happens?
I should mention that there are a couple differences between my employee1 field and my employee2 field: employee1 was created alongside the rest of the scratch org when my metadata was pushed to it, whereas employee2 was created manually after the scratch org was made. Also, when I inspect field in object setup and click the "Where is this used? (BETA)" button, the employee1 field lists just the main Lead layout, whereas employee2 lists the various Lead layouts as well as the AMS360 Employee layout.
I imagine that this has something to do with field permissions, visibility, or page layouts. However I have absolutely no idea why this issue doesn't happen when I populate two identical fields at once. Does anyone have any advice?
EDIT: Here are my JSON files:
Employees-and-Leads-plan.json
[
{
"sobject": "SIV__AMS360_Employee__c",
"saveRefs": true,
"resolveRefs": true,
"files": [
"SIV__AMS360_Employee__c.json"
]
},
{
"sobject": "Lead",
"saveRefs": true,
"resolveRefs": true,
"files": [
"Lead.json"
]
}]
SIV__AMS360_Employee__c.json
{
"records": [
{
"attributes": {
"type": "SIV__AMS360_Employee__c",
"referenceId": "EmpRef1"
},
"Name": "VPA",
"SIV__AMS360_Employee_Code__c": "!!\"",
"SIV__AMS360_Is_Executive__c": true,
"SIV__AMS360_Is_Representative__c": true
}
]}
Lead.json (this is the version that causes the error)
{
"records": [
{
"attributes": {
"type": "Lead",
"referenceId": "LeadRef1"
},
"LastName": "Lead2",
"FirstName": "Jay",
"Company": "MyCompany",
"SIV__AMS360_Employee_Lead_Exec__c": "@EmpRef1"
}
]}
Lead.json (this version works successfully for some reason because it has an additional employee field with the same reference)
{
"records": [
{
"attributes": {
"type": "Lead",
"referenceId": "LeadRef1"
},
"LastName": "Lead2",
"FirstName": "Jay",
"Company": "MyCompany",
"SIV__MyEmployeeField__c": "@EmpRef1",
"SIV__AMS360_Employee_Lead_Exec__c": "@EmpRef1"
}
]}