Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upsert on a reference field #112

Open
haileyneorsd opened this issue Jun 8, 2023 · 0 comments
Open

upsert on a reference field #112

haileyneorsd opened this issue Jun 8, 2023 · 0 comments

Comments

@haileyneorsd
Copy link

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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant