Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public with sharing class DataTableServerContrl {
- @AuraEnabled
- public static Map<object,object> fetchOpportunities(String limitSize, String offsetSize) {
- Map<object,object> contrlRes = new Map<object,object>{
- 'records' => null,
- 'fieldApiAndDataTypes' => null,
- 'fieldLabels' => null,
- 'totalSize' => null
- };
- system.debug('***limitSize: '+limitSize);
- system.debug('***limitSize: '+offsetSize);
- List<Schema.FieldSetMember> oppFields = LightningUtility.getFieldSetFields('Opportunity','Opportunity_ReadableFields');
- String selFieldsStr = LightningUtility.getFieldApiNames4QueryString(oppFields,'Opportunity');
- system.debug('selFieldsStr: '+selFieldsStr);
- String theQuery = LightningUtility.getQueryString('Opportunity',selFieldsStr,limitSize,offsetSize);
- system.debug('theQuery: '+theQuery);
- //contrlRes.put('fieldApiAndDataTypes', LightningUtility.getFieldApisLstOfFieldSet(oppFields));
- system.debug('***'+LightningUtility.getFieldApisAndDTyesLstOfFieldSet(oppFields,'Opportunity'));
- contrlRes.put('fieldApiAndDataTypes', LightningUtility.getFieldApisAndDTyesLstOfFieldSet(oppFields,'Opportunity'));
- system.debug('@@@'+contrlRes.get('fieldApiAndDataTypes'));
- contrlRes.put('fieldLabels', LightningUtility.getFieldLabelsLstOfFieldSet(oppFields,'Opportunity'));
- contrlRes.put('records', Database.query(theQuery));
- contrlRes.put('totalSize', Database.query(LightningUtility.getQueryString('Opportunity',selFieldsStr,null,null)).size());
- return contrlRes;
- }
- @AuraEnabled
- public static Opportunity fetchOpportunity(String oppId) {
- return [select Name, Amount from Opportunity where id =: oppId];
- }
- @AuraEnabled
- public static String updateOpp(String oppId, Decimal amt) {
- String statusMsg = 'Success';
- try {
- update new Opportunity(Id = oppId, Amount = amt);
- }
- catch(Exception e) {
- statusMsg = 'Error: '+e.getMessage();
- }
- return statusMsg;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement