1

I'm allowing a user to upload multiple files for accounts, contacts, and trades. Contact looks up to Accounts via a lookup field while trades look up to accounts via a master-detail relationship.

I've been able to insert both accounts and contacts successfully, but I'm running into issues inserting trades.

I'm inserting contacts that look up to accounts using:

tempContact.Account = new Account(MasterID__c=inputValuesContact[7]); (no issues)

and similarily trying to insert trades with:

tempTrade.Account__c= new Account(MasterID__c=inputvaluesTrade[0]); 

For trades I'm getting the error: Illegal assignment from Account to Id.

Am I missing something obvious? I've tried inserting with tempTrade.Account__r.Name but received a similar error: Illegal assignment from String to Id.

1 Answer 1

2

__c always refers to the Id, which is similar to AccountId. Using __r is the similar to using Account (by contrast):

tempTrade.Account__r = new Account(MasterID__c=inputvaluesTrade[0]); 
1
  • @SF2321 You're welcome! Always glad to help!
    – sfdcfox
    Commented Apr 17, 2018 at 2:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .