Created
June 2, 2015 06:51
-
-
Save oscartcy/fb292f02608ae7e81bf5 to your computer and use it in GitHub Desktop.
future method does not support list of objects
flatten to string to pass complex data structure
Also avoid breaking all batch DML operation with a flag
This file contains hidden or 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
| @future | |
| // future method does not support list of objects, so we are going to use | |
| // so tweak method in order to pass necessary info to create new PermissionSetAssignment | |
| private static void createPermissionSetAssignments(List<String> createData) { | |
| List<PermissionSetAssignment> insertPSAs = new List<PermissionSetAssignment>(); | |
| for(String data : createData) { | |
| String[] ids = data.split(';'); | |
| PermissionSetAssignment psa = new PermissionSetAssignment( | |
| PermissionSetId = ids[0], | |
| AssigneeId = ids[1] | |
| ); | |
| insertPSAs.add(psa); | |
| } | |
| try { | |
| // set second param as 'false' to continue batch DML even though one of the DML throws exception | |
| Database.insert(insertPSAs, false); | |
| } catch (DmlException e) { | |
| System.debug(e.getMessage()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment