Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. public class LWLeaseCountExtensionsController {
  2.  
  3. @AuraEnabled(cacheable=true)
  4. public static List<Account> getAccount(String AccId) {
  5. return [SELECT Id,LeaseWaveID__c, LW_Customer_ID__c, LW_Fleet_ID__c, LW_Account_ID__c, LW_SubAccount_ID__c from Account where Id=:AccId Limit 1];
  6. }
  7.  
  8. @AuraEnabled()
  9. public integer lc;
  10.  
  11. /*This was the original code that I tried first, but since it didn't work with a return type of Integer, I commented out the below method and created the next method which take a list of Integer as return type */
  12. @AuraEnabled(cacheable=true)
  13. public static Integer getLeaseCount(string LeaseWaveID) {
  14. Integer lc = !string.isblank(LeaseWaveID) ? [SELECT COUNT() FROM DW_oData_vw_sf_Units__x WHERE Lease__c = TRUE AND LeasewaveId__c =:LeaseWaveID] : -1;
  15.  
  16. @AuraEnabled(cacheable=true)
  17. public static List<Integer> getLeaseCount(string LeaseWaveID) {
  18. //List<integer> lc = !string.isblank(LeaseWaveID) ? [SELECT COUNT() FROM DW_oData_vw_sf_Units__x WHERE Lease__c = TRUE AND LeasewaveId__c =:LeaseWaveID] : -1;
  19. List<integer> lc;
  20. Integer i;
  21. if(LeaseWaveID!=null)
  22. i=[SELECT COUNT() FROM DW_oData_vw_sf_Units__x WHERE Lease__c = TRUE AND LeasewaveId__c =:LeaseWaveID];
  23. else
  24. i=-1;
  25. lc.add(i);
  26. system.debug('leaseWaveID1--'+lc);
  27. return lc;
  28. }
  29.  
  30. }
  31.  
  32. import { LightningElement,api,wire,track } from 'lwc';
  33. //import { getSObjectValue } from '@salesforce/apex';
  34. import getAccount from '@salesforce/apex/LWLeaseCountExtensionsController.getAccount';
  35. import Account_LeaseWaveId from '@salesforce/schema/Account.LeaseWaveID__c';
  36. import getLeaseCount from '@salesforce/apex/LWLeaseCountExtensionsController.getLeaseCount';
  37.  
  38. export default class TestLWLeaseCountwebComponent extends LightningElement {
  39. @api recordId;
  40. @track getLeaseCount;
  41. @api totalLC;
  42.  
  43. @wire(getAccount,{AccId:'$recordId' })
  44. accounts;
  45.  
  46. @wire(getLeaseCount, { LeaseWaveID: Account_LeaseWaveId})
  47. odata;
  48.  
  49. totalLC = JSON.stringify(this.lc);
  50. }
  51.  
  52. <template>
  53. <lightning-card title="LWCount" icon-name="custom:custom63">
  54. <div class="boarder">
  55. <!-- <p class=”slds-m-bottom_small”>
  56. <lightning-button label=”LoadContacts” onclick={handleLoad}></lightning-button>
  57. </p> -->
  58. <template if:true={accounts.data}>
  59. {LeaseWaveID}
  60. </template>
  61. {totalLC}
  62. <template if:true={odata.data}></template>
  63. </div>
  64. </lightning-card>
  65. </template>
  66.  
  67. <template>
  68. <div class="boarder">
  69. <template if:true={accounts.data}>
  70. <ui>
  71. <template for:each={accounts.data} for:item="acc">
  72. <li key={acc.Id}>{acc.LeaseWaveID__c}</li>
  73. </template>
  74. </ui>
  75. </template>
  76. </div>
  77. </template>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement