Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. /**
  2. * @description Method to insert a list of sObject
  3. * @param sObjListStr - serialized list of sObjects to be inserted
  4. * @return List<String> - returns the Ids of the created object
  5. */
  6. @AuraEnabled
  7. public static List<String> insertSObject(String sObjListStr) {
  8. List<sObject> sObjList = (List<sObject>) JSON.deserialize(sObjListStr, List<sObject>.class);
  9. List<String> successIdList = new List<String>();
  10. if (!sObjList.isEmpty()) {
  11. Database.SaveResult[] saveResults = Database.insert(sObjList, false);
  12. // Iterate through each returned result and return false if there are errors
  13. for (Database.SaveResult sr : saveResults) {
  14. if (sr.isSuccess()) {
  15. successIdList.add(sr.getId());
  16. }
  17. }
  18. }
  19. return successIdList;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement