Last active
October 14, 2015 16:12
-
-
Save tyoshikawa1106/088ae264d825abe3bc30 to your computer and use it in GitHub Desktop.
Apexの承認プロセス・ロックとロック解除
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
Account acct = [SELECT Id from Account WHERE ID = '001B0000003nOuy' LIMIT 1]; | |
Approval.UnLockResult result = Approval.unlock(acct, false); |
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
Account acct = [SELECT Id from Account WHERE ID = '001B0000003nOuy' LIMIT 1]; | |
Approval.LockResult result = Approval.lock(acct, false); |
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
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