Last active
July 1, 2020 21:45
-
-
Save salesforceBen/81927472881d46ecd7d4cf2384cb96bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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