How can I give field level security to the fields on profile basis
I have referred sample on how to update the records but I'm not sure how this helps me on giving FLS to the fields. Because I need to handle multiple conditions over here for granting FLS to filed.
private static void updateAccounts() {
System.out.println("Update the 5 new test Accounts...");
SObject[] records = new SObject[5];
try {
QueryResult queryResults = connection.query("SELECT Id, Name FROM Account ORDER BY " +
"CreatedDate DESC LIMIT 5");
if (queryResults.getSize() > 0) {
for (int i=0;i<queryResults.getRecords().length;i++) {
SObject so = (SObject)queryResults.getRecords()[i];
System.out.println("Updating Id: " + so.getId() + " - Name: "+so.getField("Name"));
// create an sobject and only send fields to update
SObject soUpdate = new SObject();
soUpdate.setType("Account");
soUpdate.setId(so.getId());
soUpdate.setField("Name", so.getField("Name")+" -- UPDATED");
records[i] = soUpdate;
}
}