Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save salesforceBen/81927472881d46ecd7d4cf2384cb96bb to your computer and use it in GitHub Desktop.
Save salesforceBen/81927472881d46ecd7d4cf2384cb96bb to your computer and use it in GitHub Desktop.
global class CSVParser
{
@RemoteAction
global static void insertAccounts(List<String> accountNames)
{
system.debug('The Account Names from the .csv are: ' + accountNames);
List<Account> accounts = new List<Account>();
Account account;
for (String accountName : accountNames)
{
account = new Account();
account.Name = accountName;
accounts.add(account);
}
system.debug('The accounts to be inserted are: ' + accounts);
if (accounts.size() > 0 && accounts.size() == accountNames.size())
{
try
{
insert accounts;
}
catch (Exception ex)
{
system.debug('There has been an error: ' + ex.getStackTraceString());
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment