Advertisement
Guest User

Untitled

a guest
Aug 26th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. public with sharing class LightningComponentController {
  2.  
  3. @AuraEnabled
  4. public static List<Object__c> getObjects() {
  5.  
  6. // Check to make sure all fields are accessible to this user
  7. String[] fieldsToCheck = new String[] {
  8. 'Id', 'Name', 'Custom_Field1__c', 'Custom_Field2__c', 'Custom_Field3__c'
  9. };
  10.  
  11. Map<String,Schema.SObjectField> fieldDescribeTokens =
  12. Schema.SObjectType.Object__c.fields.getMap();
  13.  
  14. for(String field : fieldsToCheck) {
  15.  
  16. if(!fieldDescribeTokens.get(field).getDescribe().isAccessible()) {
  17.  
  18. throw new System.NoAccessException();
  19. return null;
  20. }
  21. }
  22.  
  23. return [SELECT Id, Name, Custom_Field1__c, Custom_Field2__c, Custom_Field3__c
  24. FROM Object__c];
  25. }
  26.  
  27. @AuraEnabled
  28. public static Object__c saveObject(Object__c object) {
  29.  
  30. // Check to make sure the object is updatable
  31. if(!Schema.getGlobalDescribe().get('Object__c').getDescribe().isUpdateable()) {
  32.  
  33. throw new System.NoAccessException();
  34. return null;
  35. }
  36.  
  37. upsert object;
  38. return object;
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement