0

I can't get this sample WSC Salesforce code to work. What am I missing? I'm trying to create a new Event for a specific Account. I don't mind querying the Account first. This seems really simple, but it's not working.

    QueryResult queryResults = connection.query("SELECT Id FROM Account WHERE Name = 'TEST'");
    Account account = (Account) queryResults.getRecords()[0];
    Event event = new Event();
    [Set required fields]
    event.setAccount(account);
    Event[] records = new Event[1];
    records[0] = event;
    SaveResult[] saveResults = connection.create(records);

The error I get is

Field name provided, Id is not an External ID or indexed field for Account
4

1 回答 1

1

您将帐户对象设置为与事件的关系,当您想使用 externalId 来解析要使用的帐户时使用。在这种情况下,您有 Id,因此可以直接设置 AccountId 字段,例如

QueryResult queryResults = connection.query("SELECT Id FROM Account WHERE Name = 'TEST'");
Account account = (Account) queryResults.getRecords()[0];
Event event = new Event();
[Set required fields]
event.setAccountId(account.getId());
Event[] records = new Event[1];
records[0] = event;
SaveResult[] saveResults = connection.create(records);
于 2014-10-11T17:32:30.410 回答