Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @description Method to insert a list of sObject
- * @param sObjListStr - serialized list of sObjects to be inserted
- * @return List<String> - returns the Ids of the created object
- */
- @AuraEnabled
- public static List<String> insertSObject(String sObjListStr) {
- List<sObject> sObjList = (List<sObject>) JSON.deserialize(sObjListStr, List<sObject>.class);
- List<String> successIdList = new List<String>();
- if (!sObjList.isEmpty()) {
- Database.SaveResult[] saveResults = Database.insert(sObjList, false);
- // Iterate through each returned result and return false if there are errors
- for (Database.SaveResult sr : saveResults) {
- if (sr.isSuccess()) {
- successIdList.add(sr.getId());
- }
- }
- }
- return successIdList;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement