부모 개체 유형에 외부 ID 필드를 사용하여 SOAP에서이 작업을 수행 할 수 있습니다.이 작업을 통해 단일 호출로 상위 & 자식 개체를 보내고 외부 ID 필드 값을 통해 자동으로 연결할 수 있습니다.
여기에 계정과 관련 연락처를 한 번에 만드는 Java의 샘플이 있습니다. 연락처는 extId__c 필드를 통해 계정과 관련됩니다. 내가이 프로그램을 실행할 때
public static void main(String[] args) throws Exception {
// login to salesforce.
PartnerConnection pc = Connector.newConnection(args[0], args[1]);
// The new Account record we're going to create.
SObject acc = new SObject();
acc.setType("Account");
acc.setField("Name", "My New Account");
acc.setField("extId__c", UUID.randomUUID().toString());
// The new Contact record we're going to create.
SObject con = new SObject();
con.setType("Contact");
con.setField("FirstName", "Simon");
con.setField("LastName", "Fell");
// This Account object we build with the relationship to the account above based
// on the extId__c field, and then we set it on the contact record
// this is the standard FK lookup using ExternalIds feature.
SObject parentAcc = new SObject();
parentAcc.setType("Account");
parentAcc.setField("extId__c", acc.getField("extId__c"));
con.setField("Account", parentAcc);
// Now we can insert both records at once
SaveResult [] sr = pc.create(new SObject [] { acc, con});
printSaveResult("Account result", sr[0]);
printSaveResult("Contact result", sr[1]);
}
private static void printSaveResult(String label, SaveResult sr) {
if (sr.isSuccess())
System.out.println(label + " success recordId is " + sr.getId());
else
System.out.println(label + " failed, reason is " + sr.getErrors()[0].getMessage());
}
, 그것은
Account result success recordId is 0013000001DFMRxAAP
Contact result success recordId is 0033000001aEgskAAC
를 인쇄 그리고 내가 웹 응용 프로그램에 로그인 할 때, 난 내 새 계정 기록을 볼 수 있으며, 관련 목록에서 자식 연락처 레코드.
많은 자식 개체에 대해 내 대답은 여전히 적용되지만 아래의 답변은 단일 수준의 계층에 비해 월등히 우수합니다. –