3

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"
    }
]}
7
  • Are you using a permission set to give field level permissions to objects? If so is the employee1 field included in this permission set? If you are using a profile check the same thing. Commented Feb 13, 2019 at 16:57
  • Permission sets: I tried going to Setup -> Permission Sets, and I only see Salesforce Console User and Survey Creator. I don't believe we're using permission sets but I could be wrong. (I'm not familiar with how they work.) Profile: I'm using the System Administrator profile. When I navigate to the profile page and view field level security for Lead, it says that System Administrator has read access and edit access for employee1 and employee2.
    – Ian Horner
    Commented Feb 13, 2019 at 17:54
  • We had to create permission sets to do development with sfdx so that we can access our custom fields. I think this is your issues. Trying creating a permission set and make sure the employee object is in there. Then assign it before trying to load the data. developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/…. Also check out developer.salesforce.com/blogs/2018/12/… Commented Feb 13, 2019 at 18:01
  • Adding a permission set didn't seem to help. I created one, gave it full access to everything in Lead and Employee, and assigned it to System Administrator. But I'm still getting the same error. :(
    – Ian Horner
    Commented Feb 13, 2019 at 18:41
  • Can you post your plan.json as well as the relevent json files to load the other records? Commented Feb 13, 2019 at 18:42

1 Answer 1

1

Found the solution. Apparently there's a bug where the import tool can't handle numbers in field names. Here's a post that explains a workaround: https://developer.salesforce.com/forums/?id=9060G0000005OE3QAM

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .