Skip to content

Instantly share code, notes, and snippets.

@tyoshikawa1106
Last active October 14, 2015 16:12
Show Gist options
  • Save tyoshikawa1106/088ae264d825abe3bc30 to your computer and use it in GitHub Desktop.
Save tyoshikawa1106/088ae264d825abe3bc30 to your computer and use it in GitHub Desktop.
Apexの承認プロセス・ロックとロック解除
Account acct = [SELECT Id from Account WHERE ID = '001B0000003nOuy' LIMIT 1];
Approval.UnLockResult result = Approval.unlock(acct, false);
Account acct = [SELECT Id from Account WHERE ID = '001B0000003nOuy' LIMIT 1];
Approval.LockResult result = Approval.lock(acct, false);
Account acc = [SELECT Id from Account WHERE ID = '001B0000003o2Xd' LIMIT 1];
Approval.LockResult result = Approval.lock(acc, false);
if (result.isSuccess()) {
// Operation was successful, so get the ID of the record that was processed
System.debug('Successfully locked Account with ID: ' + result.getId());
} else {
// Operation failed, so get all errors
for(Database.Error err : result.getErrors()) {
System.debug('The following error has occurred.');
System.debug(err.getStatusCode() + ': ' + err.getMessage());
System.debug('Account fields that affected this error: ' + err.getFields());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment