-
ChatterFeed
-
0Best Answers
-
1Likes Received
-
0Likes Given
-
5Questions
-
5Replies
visualforce page not displaying data pulled in through rest call
I have a visual force page as a hyperlink on account details page. I would like to display information about contracts related to that particalar account through the page. There is a catch through, users accessing the page does not have access to contract object, so I built a rest call to call the page as me everytime they try to access the page. I checked the debug logs, contract details are being pulled in, but are all the user can see is blank spaces on vf page. I am posting my code, please let me know what I am doing wrong.
Vf page:
Controller:
Api:
Would really appreciate any help in this.
Thanks,
Krishna Vegiraju
Vf page:
<apex:page standardController="Account" extensions="ContractdetailsfromaccountController" > <apex:outputPanel > <div style="float:Left;margin-top:2em;font-family: sans-serif;font-size:12px;/*width:50%;*/"> <b>Account Name: {!Account[0].Name}<br/> Account Phone: {!Account[0].Phone}</b><br/> <apex:outputPanel rendered="{!!error}"> <b>Contact: {!contracts[0].Welcome_Letter_Recipient__r.Name}</b><br/> </apex:outputPanel> </div> </apex:outputPanel> <br/><br/><br/><br/><br/><br/> <apex:outputPanel rendered="{!error}"> <td style="font-family: sans-serif;font-size:30px;padding-left: 0.6em;padding-right: 0.6em;"><b>This Account Does not have any contracts linked to it. </b></td> </apex:outputPanel> <br/><br/> <apex:outputPanel rendered="{!!error}"> <apex:form > <apex:commandLink styleclass="start" target="_blank" onclick="window.open('/apex/Contractdetailsfromaccount', 'width=300, height=250' return false;"/> <apex:pageblock > <apex:repeat value="{!contracts}" var="con" id="therepeat"> <apex:pageBlockSection title="Contract Details" collapsible="false" columns="2" > <apex:outputText label="Contract Number" value="{!con.Name}"/> <apex:outputText value="{!con.cllease__Lease_Status__c}"/> <apex:outputText label="Funded Amount" value="{0}{1, number, ###,##0.00}"><apex:param value="$"/><apex:param value="{!con.cllease__Lease_Receivable_Amount__c}"/></apex:outputText> <apex:outputText label="Opportunity Owner" value="{!con.Opportunity_Owner_Sales_Rep__c}"/> <apex:outputText label="Payment Amount" value="{0}{1, number, ###,##0.00}"><apex:param value="$"/><apex:param value="{!con.cllease__Payment_Amount__c}"/></apex:outputText> <apex:outputText label="Channel" value="{!con.Sales_Channel__c}"/> <apex:outputText label="Total Due Amount" value="{0}{1, number, ###,##0.00}"><apex:param value="$"/><apex:param value="{!con.cllease__Amount_to_Current__c}"/></apex:outputText> <apex:outputText value="{!con.cllease__Term__c}"/> <apex:InputCheckbox value="{!con.Ever_Delinquent__c}" disabled="true"/> <apex:outputText label="Start Date" value="{0,date,MM'/'dd'/'yyyy}"><apex:param value="{!con.cllease__Commencement_Date__c}"/></apex:outputText> <apex:outputText label="Delinquent Amount" value="{0}{1, number, ###,##0.00}"><apex:param value="$"/><apex:param value="{!con.cllease__Delinquent_Amount__c}"/></apex:outputText> <apex:outputText label="End Date" value="{0,date,MM'/'dd'/'yyyy}"><apex:param value="{!con.cllease__Maturity_Date__c}"/></apex:outputText> <apex:outputText label="Delinquent Days" value="{!con.cllease__Days_Past_Due__c}"/> <apex:outputText label="Next Due Date" value="{0,date,MM'/'dd'/'yyyy}"><apex:param value="{!con.cllease__Next_Due_Date__c}"/></apex:outputText> <apex:outputText label="Outstanding Bills" value="{!con.cllease__Dues_Details__r.size}"/> <apex:outputText label="Gross Yield" value="{0, number, ###,##0.00}{1}"><apex:param value="{!con.Gross_Yield__c}"/><apex:param value="%"/></apex:outputText> <apex:outputText value="{!con.Pre_Payment_Option__c}"/> <apex:outputText label="Net Yield" value="{0, number, ###,##0.00}{1}"><apex:param value="{!con.Net_Yield__c}"/><apex:param value="%"/></apex:outputText> <apex:InputCheckbox value="{!con.Early_Buyout_Option__c}" disabled="true"/> <apex:InputCheckbox label="Set up on ACH?" value="{!con.ACH_Configured__c}" disabled="true"/> <apex:outputText value="{!con.Same_as_Cash_Option__c}"/> <apex:outputText label="Pieces of Equipment" value="{!con.cllease__Contract_Equipments__r.size}"/> <apex:outputText label="No of Payments Remaining" value="{!con.cllease__Payment_Streams__r.size}"/> <!---<apex:InputCheckbox rendered="{!AND(con.cllease__Charges__r !=Null, con.cllease__Charges__r.size>0)}" label="Enrolled in Insurance?" value="{!EPP}" disabled="true"/> <apex:InputCheckbox rendered="{!AND(con.cllease__Charges__r !=Null,con.cllease__Charges__r.size=0)}" label="Enrolled in Insurance?" value="{!EPPfalse}" disabled="true"/>---> <apex:outputText /> <apex:outputText /> <apex:outputText /> <!---<apex:outputText label="Insurance Payment Amount" value="${!IF((con.cllease__Charges__r.size>0),con.cllease__Charges__r[0].cllease__Original_Amount__c,0.00)}"/>---> <br/> <div style="border: 3px solid #afb3b1;border-radius:0px;background-color:#afb3b1;color:black;width:200%;text-align:Left;font-size:11px;font-family: sans-serif"><b>Equipment Information</b></div> <apex:repeat value="{!con.cllease__Contract_Equipments__r}" var="Equip"> <tr> <apex:outputText value="{!Equip.Equipment_Type_Name__c}"/> <apex:outputText value="{!Equip.Equipment_Sub_Type_Name__c}"/> <apex:outputText value="{!Equip.cllease__Total_Dealer_Charges__c}"/> <apex:outputText value="{!Equip.cllease__Make__c}"/> <apex:outputText value="{!Equip.cllease__Equipment_Description__c}"/> <apex:outputText value="{!Equip.cllease__Model__c}"/> <div style="width:200%; height:1px; background:grey;"></div> </tr> </apex:repeat> </apex:pageBlockSection> </apex:repeat> </apex:pageblock> </apex:form> </apex:outputPanel> </apex:page>
Controller:
public without sharing class ContractdetailsfromaccountController { public list<cllease__Lease_Account__c> contracts {get; set;} public List<Account> Account {get; set;} public boolean error {set; get;} public boolean EPP {set; get;} public boolean EPPfalse {set; get;} public ContractdetailsfromaccountController(ApexPages.standardController Acc){ Account = [select id, Name, Phone from Account where Id =: Acc.getId()]; HttpResponse resp = getRecord(); if(resp != null && resp.getStatusCode() == 200) { System.debug(resp.getBody()); contracts = (list<cllease__Lease_Account__c>) JSON.deserialize(resp.getBody(), list<cllease__Lease_Account__c>.class); } EPP=true; EPPfalse =false; If(contracts == null || contracts.size()==0){ error =true; } } public HttpResponse getRecord() { Map<String, String> authDetail; Integration_Details__c cred = Integration_Details__c.getInstance('ContractAccess'); if(cred != null) { Blob decryptedData = Crypto.decryptWithManagedIV('AES256', EncodingUtil.base64Decode(cred.Key__c), EncodingUtil.base64Decode(cred.Password__c)); authDetail = getSessionId(cred.Instance_URL__c, cred.UserName__c, decryptedData.toString()); } else { // error handling } HttpRequest req = new HttpRequest(); req.setEndpoint(cred.Instance_URL__c+'/services/apexrest/contractDetailsFromAccount/'+Account[0].Id); req.setMethod('GET'); req.setHeader('Authorization', 'OAuth ' + authDetail.get('sessionId')); System.debug(req); return new Http().send(req); } public Map<String, String> getSessionId(String url, String username, String password) { Map<String, String> authDetails; String sessionId; String email; HttpRequest request = new HttpRequest(); request.setEndpoint(url+'/services/Soap/u/44.0'); request.setMethod('POST'); request.setHeader('Content-Type', 'text/xml;charset=UTF-8'); request.setHeader('SOAPAction', '""'); // creating soap xml request request.setBody('<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Header/><Body><login xmlns="urn:partner.soap.sforce.com"><username>' + username + '</username><password>' + password + '</password></login></Body></Envelope>'); HttpResponse resp = new Http().send(request); if(resp != null && resp.getStatusCode() == 200) { Dom.Document doc = resp.getBodyDocument(); sessionId = doc.getRootElement().getChildElement('Body','http://schemas.xmlsoap.org/soap/envelope/').getChildElement('loginResponse','urn:partner.soap.sforce.com') .getChildElement('result','urn:partner.soap.sforce.com').getChildElement('sessionId','urn:partner.soap.sforce.com').getText(); email = doc.getRootElement().getChildElement('Body','http://schemas.xmlsoap.org/soap/envelope/').getChildElement('loginResponse','urn:partner.soap.sforce.com') .getChildElement('result','urn:partner.soap.sforce.com').getChildElement('userInfo','urn:partner.soap.sforce.com').getChildElement('userEmail','urn:partner.soap.sforce.com').getText(); System.debug('sending request as '+email); authDetails = new Map<String, String>(); authDetails.put('sessionId', sessionId); authDetails.put('email', email); } else { System.debug('resp error: '+resp.getBody()); } return authDetails; } }
Api:
@RestResource(urlMapping = '/contractDetailsFromAccount/*') global class ContractDetailsAPI { @HttpGET global static List<cllease__Lease_Account__c> getContractsFromAccount() { RestRequest req = RestContext.request; RestResponse res = RestContext.response; String accId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1); list<cllease__Lease_Account__c> contracts = [select id, name, cllease__Account__c, cllease__Account__r.name,Account_Phone__c, cllease__Lease_Status__c,ACH_Configured__c, cllease__Lease_Receivable_Amount__c,cllease__Commencement_Date__c,cllease__Maturity_Date__c,cllease__Payment_Amount__c, cllease__Next_Due_Date__c,cllease__Amount_to_Current__c,cllease__Delinquent_Amount__c, Net_Yield__c, Gross_Yield__c, cllease__Term__c, Opportunity_Owner_Sales_Rep__c,Sales_Channel__c, cllease__Days_Past_Due__c,Welcome_Letter_Recipient__c,Welcome_Letter_Recipient__r.Name, Early_Buyout_Option__c,Pre_Payment_Option__c,Same_as_Cash_Option__c,Ever_Delinquent__c, (select id, cllease__Payment_Satisfied__c from cllease__Dues_Details__r where cllease__Payment_Satisfied__c=false), (select id, cllease__Billed__c, cllease__Active__c from cllease__Payment_Streams__r where cllease__Billed__c=false and cllease__Active__c=true), (select id, cllease__Fee_Definition__c, cllease__Fee_Definition__r.Name, cllease__Original_Amount__c from cllease__Charges__r where cllease__Fee_Definition__r.Name='Equipment Protection Program'), (select id, cllease__Equipment_Cost__c, Equipment_Type_Name__c, Equipment_Sub_Type_Name__c, cllease__Equipment_Description__c, cllease__Model__c, cllease__Make__c,cllease__Equipment_Serial_Number__c, cllease__Total_Dealer_Charges__c from cllease__Contract_Equipments__r order by cllease__Equipment_Cost__c DESC) from cllease__Lease_Account__c where cllease__Account__c =: accId and cllease__Lease_Status__c !='PARTIAL APPLICATION' order by createddate DESC]; return contracts; } }
Would really appreciate any help in this.
Thanks,
Krishna Vegiraju
- Krishna Vegiraju
- March 17, 2020
- Like
- 0
Generate nacha file using apex class
I need to create a batch class to generate a nacha file for payments due the next day to send it to the bank. Is this possible using apex?
- Krishna Vegiraju
- January 03, 2020
- Like
- 1
I have a class in the org that has a code coverage at 0%. None of the test classes fail when i Run all tests. How do I find out the test class for this particular class.
global Class CongaImpl{ static String version = '/services/Soap/u/39.0/'; static String partnerUrl = Url.getSalesforceBaseUrl().toExternalForm()+version+UserInfo.getOrganizationId().subString(0,15); static String congaUrl; Webservice static string leaseAgreementDocument(String recordId) { // string queid='[Borrower]Label.Borrower_details,[Amortization]Label.Amortization_details,[Equipment]Label.Equipment_Details&TemplateId=Label.Hyphecation_agreement'; // System.debug('>>##Lease_Agreement_letter#:'+getQerystring('Lease_Agreement_letter')); //[Borrowersdetails]a0p5D000000D7Ce Lease_Agreement_letter // congaUrl=Label.Conga_URL+userinfo.getsessionId()+'&serverUrl='+partnerUrl+'&QueryId='+getQerystring('Lease_Agreement_letter')+'&DS7=1&OFN='+bName.deleteWhitespace()+'_LA&id='+recordId.subString(0,15); congaUrl = Label.Conga_URL+userinfo.getsessionId()+'&serverUrl='+partnerUrl+'&Id='+recordId+'&QueryId=[LA]a8G1k0000004KsR,[EQ]a8G1k0000004KsW&TemplateId=a8O1k0000008dpp&DefaultPDF=1' ; System.debug('congaUrl'+congaUrl); return getCalloutToConga(congaUrl); } public static String getCalloutToConga(String url) { system.debug('## URL ::'+url); // Instantiate a new http object Http h = new Http(); // Instantiate a new HTTP request, specify the method (GET) as well as the endpoint HttpRequest req = new HttpRequest(); req.setEndpoint(url); req.setMethod('GET'); req.setTimeout(60000); // Send the request, and return a response try{ HttpResponse res = h.send(req); if(res.getStatusCode() != 200){ system.debug('## status <>200'+res); return res.getStatus(); } else if(!Pattern.matches('[a-zA-Z0-9]{18}',res.getBody())){ system.debug('## status ==200'+res); return res.getBody(); } } catch(System.CalloutException em){ System.debug('## Callout Error message: '+em.getMessage()); } return 'Document Created successfully!!'; } }This is the class. I tried to check if any of the methods are being called in any of the test classes but no luck there either. Any help would be appreciated.
- Krishna Vegiraju
- September 26, 2019
- Like
- 0
Email not working some times
Hi,
I have a method that is being called from a trigger, when status on application changes to "approved" and send mails to particular users. It is working fine most of times but not generating mails for some records, I am unable to figure out the reason for it. the same records when tried again would generate mails but they dont the first time. Please go through the class I have an let me know where I am going wrong
I have a method that is being called from a trigger, when status on application changes to "approved" and send mails to particular users. It is working fine most of times but not generating mails for some records, I am unable to figure out the reason for it. the same records when tried again would generate mails but they dont the first time. Please go through the class I have an let me know where I am going wrong
public class ApplicationsTriggerHelper { private static Boolean fundingChecklistTriggered= false; public static void sendFundingChecklistTransEmails(Map<Id, genesis__Applications__c> newApps, Map<Id, genesis__Applications__c> oldAppsMap) { Map<genesis__Applications__c, List<Funding_Checklist_Transaction__c>> oppsToCTS = new Map<genesis__Applications__c, List<Funding_Checklist_Transaction__c>>(); Set<Id> appIds = new Set<Id>(); if(fundingChecklistTriggered) return; system.debug('fundingchecklist:-->' +fundingChecklistTriggered); for(genesis__Applications__c app: newApps.values()) { if(app.genesis__Status__c == 'APPROVED' && app.genesis__Status__c != oldAppsMap.get(app.Id).genesis__Status__c) appIds.add(app.Id); system.debug('App:--->'+app.Id); } //system.debug('App:--->'+app.Id); for(genesis__Applications__c app: [Select Id, Name, OwnerId, of_Downpayments__c, Opportunity_Id__c, Opportunity_Id__r.OwnerId, genesis__Term__c, Opportunity_Id__r.Name, genesis__Account__c, genesis__account__r.name, genesis__Financed_Amount__c,LastModifiedDate,Owner.Name, (Select Id, Application_Id__c, OwnerId, Credit_Stipulation_Name__c, Name From Funding_Checklist_Transactions__r) From genesis__Applications__c Where Id in :appIds]) { for(Funding_Checklist_Transaction__c ct: app.Funding_Checklist_Transactions__r) { if(oppsToCTS.containsKey(app)) { List<Funding_Checklist_Transaction__c> cts = oppsToCTS.get(app); cts.add(ct); oppsToCTS.put(app, cts); } else { List<Funding_Checklist_Transaction__c> cts = new List<Funding_Checklist_Transaction__c>(); cts.add(ct); oppsToCTS.put(app, cts); } } } System.debug('oppsToCTS: '+oppsToCTS); List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>(); for(genesis__Applications__c app: oppsToCTS.keySet()) { List<Funding_Checklist_Transaction__c> cts = oppsToCTS.get(app); //genesis__Applications__c app = newApps.get(appId); Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); Set<Id> toAddress = new Set<Id>{app.OwnerId}; List<Id> address = new List<Id>(); address.addAll(Label.FundingTransactionEmails.split(';')); toAddress.addAll(address); if(app.Opportunity_Id__c != null) toAddress.add(app.Opportunity_Id__r.OwnerId); mail.setSubject(app.name+' For ' +((app.genesis__Account__r.name != null) ? app.genesis__Account__r.name : '')+ ' has been APPROVED' ); String body = 'Congratulations! <br/><br/>'; body += app.Name+' for '+((app.genesis__account__r.name != null) ? app.genesis__account__r.name : '')+' has been approved for ' +app.genesis__Financed_Amount__c+ ' with a ' +app.genesis__Term__c+ ' month term. Please contact your NewLane Business Development Representative for additional details.'; //body += 'Appln Id- '+app.Id+' linked to Opp Id- '+app.Opportunity_Id__c+' has been updated with Credit Stipulations by the Credit Analyst. '+((app.OwnerId != null) ? app.Owner.Name : '')+' dated '+app.LastModifiedDate+'. <br/><br/>'; body += '<br/><br/><b>Below are the Documents Required for Funding-</b><br/><br/>'; for(Funding_Checklist_Transaction__c ct: cts) { toAddress.add(ct.OwnerId); body+= ct.Credit_Stipulation_Name__c+' <br/>'; } body += '<br/>You can also view the credit stipulations on your Opportunity:'; body += '<a Href="'+URL.getSalesforceBaseUrl().toExternalForm() +'/'+app.Opportunity_Id__c+'"> Click to open Opportunity.</a><br/><br/>'; body +='<br/>Regards, <br/><b>NewLane Finance</b><br/><br/>Thank you.<br/><br/>This is an auto-generated mail, please do not respond.'; mail.setToAddresses(new List<Id>(toAddress)); mail.setHtmlBody(body); emails.add(mail); } Messaging.sendEmail(emails); fundingChecklistTriggered = true; } }I checked the debug logs, when the record is updated the first time, Oppstocts list is returning null, You can see in the code when i set the debug for that.
- Krishna Vegiraju
- August 21, 2019
- Like
- 0
merging all the email alerts into one
Hey all,
I am facing an issue with email alerts. Who ever previously worked before me had email alert set to go out through process builder when ever a record is created in an object to the owner of the application. These records are created in 'funding checklist' object inside oportunity. the problem is, users are complaining that they are getting a seperate email for each of those records. they want all the records related to that opportunity to be mentioned in one email and not mutiple emails. how do i tackle this situation.
I am facing an issue with email alerts. Who ever previously worked before me had email alert set to go out through process builder when ever a record is created in an object to the owner of the application. These records are created in 'funding checklist' object inside oportunity. the problem is, users are complaining that they are getting a seperate email for each of those records. they want all the records related to that opportunity to be mentioned in one email and not mutiple emails. how do i tackle this situation.
- Krishna Vegiraju
- August 13, 2019
- Like
- 0
Generate nacha file using apex class
I need to create a batch class to generate a nacha file for payments due the next day to send it to the bank. Is this possible using apex?
- Krishna Vegiraju
- January 03, 2020
- Like
- 1
visualforce page not displaying data pulled in through rest call
I have a visual force page as a hyperlink on account details page. I would like to display information about contracts related to that particalar account through the page. There is a catch through, users accessing the page does not have access to contract object, so I built a rest call to call the page as me everytime they try to access the page. I checked the debug logs, contract details are being pulled in, but are all the user can see is blank spaces on vf page. I am posting my code, please let me know what I am doing wrong.
Vf page:
Controller:
Api:
Would really appreciate any help in this.
Thanks,
Krishna Vegiraju
Vf page:
<apex:page standardController="Account" extensions="ContractdetailsfromaccountController" > <apex:outputPanel > <div style="float:Left;margin-top:2em;font-family: sans-serif;font-size:12px;/*width:50%;*/"> <b>Account Name: {!Account[0].Name}<br/> Account Phone: {!Account[0].Phone}</b><br/> <apex:outputPanel rendered="{!!error}"> <b>Contact: {!contracts[0].Welcome_Letter_Recipient__r.Name}</b><br/> </apex:outputPanel> </div> </apex:outputPanel> <br/><br/><br/><br/><br/><br/> <apex:outputPanel rendered="{!error}"> <td style="font-family: sans-serif;font-size:30px;padding-left: 0.6em;padding-right: 0.6em;"><b>This Account Does not have any contracts linked to it. </b></td> </apex:outputPanel> <br/><br/> <apex:outputPanel rendered="{!!error}"> <apex:form > <apex:commandLink styleclass="start" target="_blank" onclick="window.open('/apex/Contractdetailsfromaccount', 'width=300, height=250' return false;"/> <apex:pageblock > <apex:repeat value="{!contracts}" var="con" id="therepeat"> <apex:pageBlockSection title="Contract Details" collapsible="false" columns="2" > <apex:outputText label="Contract Number" value="{!con.Name}"/> <apex:outputText value="{!con.cllease__Lease_Status__c}"/> <apex:outputText label="Funded Amount" value="{0}{1, number, ###,##0.00}"><apex:param value="$"/><apex:param value="{!con.cllease__Lease_Receivable_Amount__c}"/></apex:outputText> <apex:outputText label="Opportunity Owner" value="{!con.Opportunity_Owner_Sales_Rep__c}"/> <apex:outputText label="Payment Amount" value="{0}{1, number, ###,##0.00}"><apex:param value="$"/><apex:param value="{!con.cllease__Payment_Amount__c}"/></apex:outputText> <apex:outputText label="Channel" value="{!con.Sales_Channel__c}"/> <apex:outputText label="Total Due Amount" value="{0}{1, number, ###,##0.00}"><apex:param value="$"/><apex:param value="{!con.cllease__Amount_to_Current__c}"/></apex:outputText> <apex:outputText value="{!con.cllease__Term__c}"/> <apex:InputCheckbox value="{!con.Ever_Delinquent__c}" disabled="true"/> <apex:outputText label="Start Date" value="{0,date,MM'/'dd'/'yyyy}"><apex:param value="{!con.cllease__Commencement_Date__c}"/></apex:outputText> <apex:outputText label="Delinquent Amount" value="{0}{1, number, ###,##0.00}"><apex:param value="$"/><apex:param value="{!con.cllease__Delinquent_Amount__c}"/></apex:outputText> <apex:outputText label="End Date" value="{0,date,MM'/'dd'/'yyyy}"><apex:param value="{!con.cllease__Maturity_Date__c}"/></apex:outputText> <apex:outputText label="Delinquent Days" value="{!con.cllease__Days_Past_Due__c}"/> <apex:outputText label="Next Due Date" value="{0,date,MM'/'dd'/'yyyy}"><apex:param value="{!con.cllease__Next_Due_Date__c}"/></apex:outputText> <apex:outputText label="Outstanding Bills" value="{!con.cllease__Dues_Details__r.size}"/> <apex:outputText label="Gross Yield" value="{0, number, ###,##0.00}{1}"><apex:param value="{!con.Gross_Yield__c}"/><apex:param value="%"/></apex:outputText> <apex:outputText value="{!con.Pre_Payment_Option__c}"/> <apex:outputText label="Net Yield" value="{0, number, ###,##0.00}{1}"><apex:param value="{!con.Net_Yield__c}"/><apex:param value="%"/></apex:outputText> <apex:InputCheckbox value="{!con.Early_Buyout_Option__c}" disabled="true"/> <apex:InputCheckbox label="Set up on ACH?" value="{!con.ACH_Configured__c}" disabled="true"/> <apex:outputText value="{!con.Same_as_Cash_Option__c}"/> <apex:outputText label="Pieces of Equipment" value="{!con.cllease__Contract_Equipments__r.size}"/> <apex:outputText label="No of Payments Remaining" value="{!con.cllease__Payment_Streams__r.size}"/> <!---<apex:InputCheckbox rendered="{!AND(con.cllease__Charges__r !=Null, con.cllease__Charges__r.size>0)}" label="Enrolled in Insurance?" value="{!EPP}" disabled="true"/> <apex:InputCheckbox rendered="{!AND(con.cllease__Charges__r !=Null,con.cllease__Charges__r.size=0)}" label="Enrolled in Insurance?" value="{!EPPfalse}" disabled="true"/>---> <apex:outputText /> <apex:outputText /> <apex:outputText /> <!---<apex:outputText label="Insurance Payment Amount" value="${!IF((con.cllease__Charges__r.size>0),con.cllease__Charges__r[0].cllease__Original_Amount__c,0.00)}"/>---> <br/> <div style="border: 3px solid #afb3b1;border-radius:0px;background-color:#afb3b1;color:black;width:200%;text-align:Left;font-size:11px;font-family: sans-serif"><b>Equipment Information</b></div> <apex:repeat value="{!con.cllease__Contract_Equipments__r}" var="Equip"> <tr> <apex:outputText value="{!Equip.Equipment_Type_Name__c}"/> <apex:outputText value="{!Equip.Equipment_Sub_Type_Name__c}"/> <apex:outputText value="{!Equip.cllease__Total_Dealer_Charges__c}"/> <apex:outputText value="{!Equip.cllease__Make__c}"/> <apex:outputText value="{!Equip.cllease__Equipment_Description__c}"/> <apex:outputText value="{!Equip.cllease__Model__c}"/> <div style="width:200%; height:1px; background:grey;"></div> </tr> </apex:repeat> </apex:pageBlockSection> </apex:repeat> </apex:pageblock> </apex:form> </apex:outputPanel> </apex:page>
Controller:
public without sharing class ContractdetailsfromaccountController { public list<cllease__Lease_Account__c> contracts {get; set;} public List<Account> Account {get; set;} public boolean error {set; get;} public boolean EPP {set; get;} public boolean EPPfalse {set; get;} public ContractdetailsfromaccountController(ApexPages.standardController Acc){ Account = [select id, Name, Phone from Account where Id =: Acc.getId()]; HttpResponse resp = getRecord(); if(resp != null && resp.getStatusCode() == 200) { System.debug(resp.getBody()); contracts = (list<cllease__Lease_Account__c>) JSON.deserialize(resp.getBody(), list<cllease__Lease_Account__c>.class); } EPP=true; EPPfalse =false; If(contracts == null || contracts.size()==0){ error =true; } } public HttpResponse getRecord() { Map<String, String> authDetail; Integration_Details__c cred = Integration_Details__c.getInstance('ContractAccess'); if(cred != null) { Blob decryptedData = Crypto.decryptWithManagedIV('AES256', EncodingUtil.base64Decode(cred.Key__c), EncodingUtil.base64Decode(cred.Password__c)); authDetail = getSessionId(cred.Instance_URL__c, cred.UserName__c, decryptedData.toString()); } else { // error handling } HttpRequest req = new HttpRequest(); req.setEndpoint(cred.Instance_URL__c+'/services/apexrest/contractDetailsFromAccount/'+Account[0].Id); req.setMethod('GET'); req.setHeader('Authorization', 'OAuth ' + authDetail.get('sessionId')); System.debug(req); return new Http().send(req); } public Map<String, String> getSessionId(String url, String username, String password) { Map<String, String> authDetails; String sessionId; String email; HttpRequest request = new HttpRequest(); request.setEndpoint(url+'/services/Soap/u/44.0'); request.setMethod('POST'); request.setHeader('Content-Type', 'text/xml;charset=UTF-8'); request.setHeader('SOAPAction', '""'); // creating soap xml request request.setBody('<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Header/><Body><login xmlns="urn:partner.soap.sforce.com"><username>' + username + '</username><password>' + password + '</password></login></Body></Envelope>'); HttpResponse resp = new Http().send(request); if(resp != null && resp.getStatusCode() == 200) { Dom.Document doc = resp.getBodyDocument(); sessionId = doc.getRootElement().getChildElement('Body','http://schemas.xmlsoap.org/soap/envelope/').getChildElement('loginResponse','urn:partner.soap.sforce.com') .getChildElement('result','urn:partner.soap.sforce.com').getChildElement('sessionId','urn:partner.soap.sforce.com').getText(); email = doc.getRootElement().getChildElement('Body','http://schemas.xmlsoap.org/soap/envelope/').getChildElement('loginResponse','urn:partner.soap.sforce.com') .getChildElement('result','urn:partner.soap.sforce.com').getChildElement('userInfo','urn:partner.soap.sforce.com').getChildElement('userEmail','urn:partner.soap.sforce.com').getText(); System.debug('sending request as '+email); authDetails = new Map<String, String>(); authDetails.put('sessionId', sessionId); authDetails.put('email', email); } else { System.debug('resp error: '+resp.getBody()); } return authDetails; } }
Api:
@RestResource(urlMapping = '/contractDetailsFromAccount/*') global class ContractDetailsAPI { @HttpGET global static List<cllease__Lease_Account__c> getContractsFromAccount() { RestRequest req = RestContext.request; RestResponse res = RestContext.response; String accId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1); list<cllease__Lease_Account__c> contracts = [select id, name, cllease__Account__c, cllease__Account__r.name,Account_Phone__c, cllease__Lease_Status__c,ACH_Configured__c, cllease__Lease_Receivable_Amount__c,cllease__Commencement_Date__c,cllease__Maturity_Date__c,cllease__Payment_Amount__c, cllease__Next_Due_Date__c,cllease__Amount_to_Current__c,cllease__Delinquent_Amount__c, Net_Yield__c, Gross_Yield__c, cllease__Term__c, Opportunity_Owner_Sales_Rep__c,Sales_Channel__c, cllease__Days_Past_Due__c,Welcome_Letter_Recipient__c,Welcome_Letter_Recipient__r.Name, Early_Buyout_Option__c,Pre_Payment_Option__c,Same_as_Cash_Option__c,Ever_Delinquent__c, (select id, cllease__Payment_Satisfied__c from cllease__Dues_Details__r where cllease__Payment_Satisfied__c=false), (select id, cllease__Billed__c, cllease__Active__c from cllease__Payment_Streams__r where cllease__Billed__c=false and cllease__Active__c=true), (select id, cllease__Fee_Definition__c, cllease__Fee_Definition__r.Name, cllease__Original_Amount__c from cllease__Charges__r where cllease__Fee_Definition__r.Name='Equipment Protection Program'), (select id, cllease__Equipment_Cost__c, Equipment_Type_Name__c, Equipment_Sub_Type_Name__c, cllease__Equipment_Description__c, cllease__Model__c, cllease__Make__c,cllease__Equipment_Serial_Number__c, cllease__Total_Dealer_Charges__c from cllease__Contract_Equipments__r order by cllease__Equipment_Cost__c DESC) from cllease__Lease_Account__c where cllease__Account__c =: accId and cllease__Lease_Status__c !='PARTIAL APPLICATION' order by createddate DESC]; return contracts; } }
Would really appreciate any help in this.
Thanks,
Krishna Vegiraju
- Krishna Vegiraju
- March 17, 2020
- Like
- 0
I have a class in the org that has a code coverage at 0%. None of the test classes fail when i Run all tests. How do I find out the test class for this particular class.
global Class CongaImpl{ static String version = '/services/Soap/u/39.0/'; static String partnerUrl = Url.getSalesforceBaseUrl().toExternalForm()+version+UserInfo.getOrganizationId().subString(0,15); static String congaUrl; Webservice static string leaseAgreementDocument(String recordId) { // string queid='[Borrower]Label.Borrower_details,[Amortization]Label.Amortization_details,[Equipment]Label.Equipment_Details&TemplateId=Label.Hyphecation_agreement'; // System.debug('>>##Lease_Agreement_letter#:'+getQerystring('Lease_Agreement_letter')); //[Borrowersdetails]a0p5D000000D7Ce Lease_Agreement_letter // congaUrl=Label.Conga_URL+userinfo.getsessionId()+'&serverUrl='+partnerUrl+'&QueryId='+getQerystring('Lease_Agreement_letter')+'&DS7=1&OFN='+bName.deleteWhitespace()+'_LA&id='+recordId.subString(0,15); congaUrl = Label.Conga_URL+userinfo.getsessionId()+'&serverUrl='+partnerUrl+'&Id='+recordId+'&QueryId=[LA]a8G1k0000004KsR,[EQ]a8G1k0000004KsW&TemplateId=a8O1k0000008dpp&DefaultPDF=1' ; System.debug('congaUrl'+congaUrl); return getCalloutToConga(congaUrl); } public static String getCalloutToConga(String url) { system.debug('## URL ::'+url); // Instantiate a new http object Http h = new Http(); // Instantiate a new HTTP request, specify the method (GET) as well as the endpoint HttpRequest req = new HttpRequest(); req.setEndpoint(url); req.setMethod('GET'); req.setTimeout(60000); // Send the request, and return a response try{ HttpResponse res = h.send(req); if(res.getStatusCode() != 200){ system.debug('## status <>200'+res); return res.getStatus(); } else if(!Pattern.matches('[a-zA-Z0-9]{18}',res.getBody())){ system.debug('## status ==200'+res); return res.getBody(); } } catch(System.CalloutException em){ System.debug('## Callout Error message: '+em.getMessage()); } return 'Document Created successfully!!'; } }This is the class. I tried to check if any of the methods are being called in any of the test classes but no luck there either. Any help would be appreciated.
- Krishna Vegiraju
- September 26, 2019
- Like
- 0
- Tina C
- April 13, 2016
- Like
- 0