• Hysteresis
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies

Hi,

 

I've been getting to grips with the Salesforce API via the Salesforce Python Toolkit recently. While I can do most of what I want to be able to do, I'm flummoxed by trying to create records containing lookup relationships. I've read a lot about using foreign keys, and making nested SObjects in Java and so on, but wondered if anyone could give me an example using the Salesforce Python Toolkit specifically.

 

For the purpose of illustration, suppose that I have two custom objects: "Project__c" and "Person__c". The project has a person associated with it using a lookup field "Associate__c" and the Person object is identified by "Ext_ID__c", 

 

This is what I've tried so far:

 

proj = sf.generateObject('Project__c')

pers = sf.generateObject('Person__c')

pers.Ext_ID__c = 'externalID'

proj.Associate__c = pers.Ext_ID__c

result = sf.create(proj)

 

In principle, the person should already exist in the database before the project is submitted. I'm not sure it this makes much of a difference.

 

I think my problem is that pers.Ext_ID__c isn't functioning as an ID, but I don't really understand why, or how to make it behave.

 

Any suggestions would be most welcome.

 

Thank you!