Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. public with sharing class DataTableServerContrl {
  2. @AuraEnabled
  3. public static Map<object,object> fetchOpportunities(String limitSize, String offsetSize) {
  4. Map<object,object> contrlRes = new Map<object,object>{
  5. 'records' => null,
  6. 'fieldApiAndDataTypes' => null,
  7. 'fieldLabels' => null,
  8. 'totalSize' => null
  9. };
  10. system.debug('***limitSize: '+limitSize);
  11. system.debug('***limitSize: '+offsetSize);
  12. List<Schema.FieldSetMember> oppFields = LightningUtility.getFieldSetFields('Opportunity','Opportunity_ReadableFields');
  13. String selFieldsStr = LightningUtility.getFieldApiNames4QueryString(oppFields,'Opportunity');
  14. system.debug('selFieldsStr: '+selFieldsStr);
  15. String theQuery = LightningUtility.getQueryString('Opportunity',selFieldsStr,limitSize,offsetSize);
  16. system.debug('theQuery: '+theQuery);
  17. //contrlRes.put('fieldApiAndDataTypes', LightningUtility.getFieldApisLstOfFieldSet(oppFields));
  18. system.debug('***'+LightningUtility.getFieldApisAndDTyesLstOfFieldSet(oppFields,'Opportunity'));
  19. contrlRes.put('fieldApiAndDataTypes', LightningUtility.getFieldApisAndDTyesLstOfFieldSet(oppFields,'Opportunity'));
  20. system.debug('@@@'+contrlRes.get('fieldApiAndDataTypes'));
  21. contrlRes.put('fieldLabels', LightningUtility.getFieldLabelsLstOfFieldSet(oppFields,'Opportunity'));
  22. contrlRes.put('records', Database.query(theQuery));
  23. contrlRes.put('totalSize', Database.query(LightningUtility.getQueryString('Opportunity',selFieldsStr,null,null)).size());
  24. return contrlRes;
  25. }
  26. @AuraEnabled
  27. public static Opportunity fetchOpportunity(String oppId) {
  28. return [select Name, Amount from Opportunity where id =: oppId];
  29. }
  30. @AuraEnabled
  31. public static String updateOpp(String oppId, Decimal amt) {
  32. String statusMsg = 'Success';
  33. try {
  34. update new Opportunity(Id = oppId, Amount = amt);
  35. }
  36. catch(Exception e) {
  37. statusMsg = 'Error: '+e.getMessage();
  38. }
  39. return statusMsg;
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement