You need to sign in to do that
Don't have an account?
Karen Outlook
Can't pass more than two arguments in an Apex Class Map - what can I use instead?
I have a line of code like this:
Map<Id,Account> contactMap = new Map<Id,Account>();
I want to keep this code, but I also want two more field values, so that values for Account ID, Title, and AssistantName are collected on a Contact record. Any tips on how to do this? I'm fairly new to Apex coding. Thank you!
Map<Id,Account> contactMap = new Map<Id,Account>();
I want to keep this code, but I also want two more field values, so that values for Account ID, Title, and AssistantName are collected on a Contact record. Any tips on how to do this? I'm fairly new to Apex coding. Thank you!
I guess you are fetching the Account from databases right - if that's the case, in your query try to fetch the Contact related details as well. After that, from Account - you can refer to a list as Account.Contacts. Size of Account.Contacts list could be >= 0 depending upon your Account and it's contacts counts.See below a sample code.
Belated thanks for your response!
I am passing information from a Web form (using Wufoo - not the Salesforce forms) to create an Account and a Contact. So I'm not fetching Accounts.
A former colleague sent the content below as a framework (I know the syntax is off for some of this, but I haven't had a chance to play with it yet.) Just wanted to tell you I appreciate your quick reply. I'll update this later if/when I have a chance to work on it further!
*******************************************
public class currentApexClass{
Account a = [Select Id From Account Limit 1].Id;
formContents fc = new formContents();
fc.Id = a.Id;
fc.title = "CEO";
fc.assistantName = "Joe Smith";
Map<Id,formContents> m = new Map<Id,formContents>();
m.put(a.Id,fc);
class formContents{
public Id accountId {get;set;}
public String title {get;set;}
public String assistantName {get;set}
}
}