Skip to content

upsert on a reference field #112

@haileyneorsd

Description

@haileyneorsd

Hello. Does anybody know how to upsert on a reference field?

Below on line#2 I create the SF job where I upsert to the 'Premise__c' object, and upsert using the 'Premise_ID__c' field. The 'Premise_ID__c' field is a reference field in the SF object. I am receiving the error: "Premise_ID__c not specified" .

Would appreciate if anybody has some knowledge around this. Thanks.

        print("Creating SF job")
        job = sf.create_upsert_job(object_name="Premise__c", external_id_name="Premise_ID__c", contentType='JSON', pk_chunking=True)
        
        #put records into data_holder using .txt file generated by previous componenet
        premise = []
        f = open('premise_one_record.txt', 'r')
        next(f)
        for line in f:
            #print(line)    
            premise.append(line.split('|'))
        
        #for each row in db, append dicts{} of records to data_holder[]
        for record in premise:
            data_holder.append({'Premise_Surrogate_ID__c':record[0],
                        "Unique_Premise__r": {"Premise_ID__c":record[1]},
                        'Name':record[2], 
                        'Premise_Address_Full__c':record[3],
                        'Premise_Address_Str1__c':record[4],
                        'Premise_Address_Str2__c':record[5],
                        'Premise_City__c':record[6],
                        'Premise_Postal__c':record[7],
                        'Premise_State__c':record[8],
                        'CityCode__c':record[9],
                        'Parcel_ID__c':record[10],
                        'Parent_Parcel_ID__c':record[11],
                        'Latitude__c':record[12],
                        'Longitude__c':record[13],
                        'SW_ERU__c':record[14],
                        'SW_Tier__c':record[15],
                        'SW_Community_Name__c':record[16],
                        'SW_Only_Flag__c':record[17],
                        'CWD_Account_Number__c':record[18],
                        "Customer_ID__r":{'Customer_ID__c':record[19]},
                        'Premise_Has_Certification__c':record[20]                
                        })
        
        f.close()

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