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.

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]); 
  • @SF2321 You're welcome! Always glad to help! – sfdcfox Apr 17 '18 at 2:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.