Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public with sharing class LightningComponentController {
- @AuraEnabled
- public static List<Object__c> getObjects() {
- // Check to make sure all fields are accessible to this user
- String[] fieldsToCheck = new String[] {
- 'Id', 'Name', 'Custom_Field1__c', 'Custom_Field2__c', 'Custom_Field3__c'
- };
- Map<String,Schema.SObjectField> fieldDescribeTokens =
- Schema.SObjectType.Object__c.fields.getMap();
- for(String field : fieldsToCheck) {
- if(!fieldDescribeTokens.get(field).getDescribe().isAccessible()) {
- throw new System.NoAccessException();
- return null;
- }
- }
- return [SELECT Id, Name, Custom_Field1__c, Custom_Field2__c, Custom_Field3__c
- FROM Object__c];
- }
- @AuraEnabled
- public static Object__c saveObject(Object__c object) {
- // Check to make sure the object is updatable
- if(!Schema.getGlobalDescribe().get('Object__c').getDescribe().isUpdateable()) {
- throw new System.NoAccessException();
- return null;
- }
- upsert object;
- return object;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement