-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
16Questions
-
30Replies
Uncaught Action failed: lightning:recordEditForm$controller$handleGetRecordCreateDefaults
Hello,
I have come across few errors after Salesforce Spring '20 release. Our aura components were working just fine but after the production upgrade to spring '20, I am getting the following errors
Erors were not there before the production upgrade. I have made sure the profiles have a default record type and also checked that the aura component have record id specifed.
Controller
Any help will be approciated
I have come across few errors after Salesforce Spring '20 release. Our aura components were working just fine but after the production upgrade to spring '20, I am getting the following errors
Erors were not there before the production upgrade. I have made sure the profiles have a default record type and also checked that the aura component have record id specifed.
<aura:component implements="force:lightningQuickActionWithoutHeader,force:hasRecordId"> <!-- Modal Style --> <aura:html tag="style"> .slds-modal__container{ height : auto; width: 30%; max-width: 500rem; } .modal-body{ height : 385px !important; max-height: 385px !important; } .customFooter{ display: inline !important; } </aura:html> <!-- Handler and attributes --> <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> <aura:attribute name="account" type="Object"/> <aura:attribute name="simpleAccount" type="Object"/> <aura:attribute name="accountError" type="String"/> <force:recordData aura:id="accountRecordLoader" recordId="{!v.recordId}" fields="Name, Disposition_Status__c" targetRecord="{!v.account}" targetFields="{!v.simpleAccount}" targetError="{!v.accountError}" /> <!-- Display a header with details about the account --> <div class="slds-page-header" role="banner"> <p class="slds-text-heading_label">{!v.simpleAccount.Name}</p> <h1 class="slds-page-header__title slds-m-right_small slds-truncate slds-align-left">No Answer No VM</h1> </div> <!-- Display the new engagement activity form --> <lightning:recordEditForm objectApiName="Engagement_Activity__c" onsuccess="{!c.handleSuccess}" recordTypeId="0120h000000CF6UAAW"> <!--Account Edit Form--> <lightning:recordEditForm objectApiName="Account" recordId="{!v.recordId}" aura:id="fDate" recordTypeId="0120h000000YQWe"> <!--Displayed Fields --> <lightning:inputField fieldName="Call_Comments__c"/> <lightning:inputField fieldName="Next_Follow_Up_Date__c"/> <lightning:inputField fieldName="Contact__c"/> <!--Hidden Fields --> <div style="display: none"> <lightning:inputField fieldName="Disposition_Status__c" aura:id="dispStat"/> </div> </lightning:recordEditForm> <div style="display: none"> <lightning:inputField fieldName="Activity_Date__c" aura:id="actDate"/> <lightning:inputField fieldName="Account__c" value="{!v.recordId}"/> <lightning:inputField fieldName="Activity_Type__c" value= "Call" /> <lightning:inputField fieldName="Call_Disposition__c" value= "No Answer No VM"/> </div> <!-- Footer of modal --> <footer class="slds-modal__footer"> <lightning:button label="Save" type="submit" onclick="{!c.handleSaveEA}" variant="brand" class="slds-m-top_medium"/> <lightning:button label="Cancel" onclick="{!c.handleCancel}" variant="brand" class="slds-m-top_medium"/> </footer> </lightning:recordEditForm> </aura:component>
Controller
({ doInit: function(component, event, helper) { var today = $A.localizationService.formatDate(new Date(), "YYYY-MM-DD"); component.find('actDate').set('v.value', today); }, handleSaveEA: function(component, event, helper) { if(component.get('v.simpleAccount.Disposition_Status__c') == 'Cold Call Not Contacted'){ component.find('dispStat').set('v.value', 'Locating DM'); } component.find('fDate').submit(); }, handleSuccess : function(component, event, helper){ window.location.reload(); }, handleCancel: function(component, event, helper) { $A.get("e.force:closeQuickAction").fire(); }, })
Any help will be approciated
- SF_Monkey
- February 11, 2020
- Like
- 0
trigger test coverage
I have trying to get atleast the passing coverage for the trigger. Trigger is working fine but I am being able to get the test coverage. It would capture the oldMap and newMap values in the test
Trigger:
Test
Coverage
Any help would be appreciated!
Trigger:
trigger allAccTrigger on Account (before update) { if(trigger.isUpdate){ if(trigger.isBefore){ if(checkRecursive.runOnce()){ List<Account> accVert = new List<Account>(); List<vendor_invoice__c> ven = new List<Vendor_Invoice__c>(); for( Id accountId : Trigger.newMap.keySet() ){ //Update the coordination checkbox after approval if(trigger.oldMap.get(accountId).Coordination_Complete__c != trigger.newMap.get(accountId).Coordination_Complete__c ){ List<Processing_Checklist__c> prop = [select name from Processing_Checklist__c where account__c = :accountId AND name Like 'Coordination List Completed']; prop[0].Completed__c = true; update prop; } if(trigger.oldMap.get(accountId).RecordTypeId != trigger.newMap.get(accountId).RecordTypeId){ List<Account> accRecType = [select RecordTypeId from account where id = :accountId]; //Check if all the vendor invoices have auditors before converting to contingency if(trigger.newMap.get(accountId).RecordtypeId == '0120h000000MclWAAS'){ for(Vendor_Invoice__c v : [select name, id from vendor_invoice__c where account__c = :accountId AND Auditor_Assignment__c = null]){ ven.add(v); } if(ven.size()> 0){ Trigger.new[0].addError('Please assign auditor to ALL related vendor invoices'); } } //Checking to see if account moved to ACAP record type and deleting everything is vertical for(Account ac : accRecType){ if(ac.RecordTypeId == '0120h000000YQmIAAW'){ accVert.add(ac); } } } } //Getting all the verticals and navigation items to delete after the record is moved to ACAP If(accVert.size() > 0) {List<Prospect__c> props = [select id from Prospect__c where account__c IN :accVert]; List<Navigate_List__c> navList = [select id from Navigate_List__c where account__c IN :accVert]; delete props; delete navList; } } } } }
Test
@isTest public class accTriggerTest { public static testMethod void casTrig(){ Account accTest = new Account(); accTest.Name = 'Test Account'; accTest.Federal_Tax_Exempted__c = true; accTest.State_Tax_Exempted__c = false; accTest.Coordination_Complete__c = false; accTest.Company_Code__c = 'ads'; accTest.RecordTypeId = '0120h000000YQWeAAO'; insert accTest; Opportunity opp = new opportunity(); opp.AccountId = accTest.id; opp.Name = 'trying'; opp.StageName = 'ACAP'; opp.Estimated_Bill_Volume__c = 100; opp.CloseDate = Date.newInstance(2020, 12, 9); opp.Business_Development_Manager__c = UserInfo.getUserId(); opp.Business_Development_Rep__c = UserInfo.getUserId(); opp.RecordTypeId = '0120h000000YQVlAAO'; opp.Credit_Shared__c = 10; opp.Saving_Shared__c = 20; insert opp; Vendor_Information__c venInfo = new Vendor_Information__c(); venInfo.name = 'tester'; venInfo.Abbreviated_Name__c = 'abc'; venInfo.Phone__c = '123456789'; insert venInfo; Vendor_Invoice__c venIn = new Vendor_Invoice__c(); venIn.Account_Number__c = 'fw df42r qe'; venIn.Account__c = accTest.Id; venIn.Vendor_Information__c = venInfo.id; venIn.Federal_Tax_Exempted__c = true; venIn.State_Tax_Exempted__c = false; venIn.Auditor_Assignment__c = UserInfo.getUserId(); insert venIn; Account_Survey__c sur = new Account_Survey__c(); sur.Account__c = accTest.id; insert sur; Case_Finding__c cas = new Case_Finding__c(); cas.Name = 'try it'; cas.Service_Type__c = 'Data'; cas.Case_Date__c = Date.newInstance(2020, 12, 9); cas.Months_To_Bill__c = 12; cas.Vendor_Invoice__c = venIn.id; cas.RecordTypeId = '0120h000000YQPxAAO'; cas.Case_Status__c = 'Active'; insert cas; Case_Finding__c cas1 = new Case_Finding__c(); cas1.Name = 'try it'; cas1.Service_Type__c = 'Data'; cas1.Case_Date__c = Date.newInstance(2020, 12, 9); cas1.Months_To_Bill__c = 12; cas1.Vendor_Invoice__c = venIn.id; cas1.RecordTypeId = '0120h000000i9oWAAQ'; cas1.Case_Status__c = 'Active'; insert cas1; List<Case_Finding__c> cList = new List<Case_Finding__c>(); cList.add(cas); cList.add(cas1); Processing_Checklist__c pro1 = new Processing_Checklist__c(); pro1.Account__c = accTest.id; pro1.Name = 'Coordination List Completed'; pro1.Notes__c = 'i really do not want to write the entire thing so i am going to end it here'; pro1.Completed__c = false; insert pro1; Acap_Checklist__c pro = new Acap_Checklist__c(); pro.Account__c = accTest.id; pro.Name = 'i dont know it yet'; pro.Notes__c = 'i really do not want to write the entire thing so i am going to end it here'; pro.Completed__c = false; insert pro; accTest.RecordTypeId = '0120h000000YQmIAAW'; accTest.Coordination_Complete__c = true; update accTest; } public static testMethod void casTrig1(){ Account accTest = new Account(); accTest.Name = 'Test Account'; accTest.Federal_Tax_Exempted__c = true; accTest.State_Tax_Exempted__c = false; accTest.Coordination_Complete__c = false; accTest.Company_Code__c = 'er'; insert accTest; opportunity opp = new opportunity(); opp.AccountId = accTest.id; opp.Name = 'trying'; opp.StageName = 'ACAP'; opp.Estimated_Bill_Volume__c = 100; opp.CloseDate = Date.newInstance(2020, 12, 9); opp.Business_Development_Manager__c = UserInfo.getUserId(); opp.Business_Development_Rep__c = UserInfo.getUserId(); opp.RecordTypeId = '0120h000000YQVlAAO'; opp.Credit_Shared__c = 10; opp.Saving_Shared__c = 20; insert opp; Vendor_Information__c venInfo = new Vendor_Information__c(); venInfo.name = 'tester'; venInfo.Abbreviated_Name__c = 'abc'; venInfo.Phone__c = '123456789'; insert venInfo; Vendor_Invoice__c venIn = new Vendor_Invoice__c(); venIn.Account_Number__c = 'fw df42r qe'; venIn.Account__c = accTest.Id; venIn.Vendor_Information__c = venInfo.id; venIn.Federal_Tax_Exempted__c = true; venIn.State_Tax_Exempted__c = false; insert venIn; Account_Survey__c sur = new Account_Survey__c(); sur.Account__c = accTest.id; insert sur; Case_Finding__c cas = new Case_Finding__c(); cas.Name = 'try it'; cas.Service_Type__c = 'LOCAL'; cas.Case_Date__c = Date.newInstance(2020, 12, 9); cas.Months_To_Bill__c = 12; cas.Vendor_Invoice__c = venIn.id; cas.RecordTypeId = '0120h000000YQPxAAO'; cas.Case_Status__c = 'Active'; insert cas; Test.startTest(); try{ accTest.RecordTypeId = '0120h000000MclWAAS'; update accTest; system.assert(true, 'Please assign auditor to ALL related vendor invoices');} catch(exception ex){ Boolean expectedExceptionThrown = ex.getMessage().contains('Script-thrown exception') ? true : false; System.assertEquals(expectedExceptionThrown, false); } Test.stopTest(); } }
Coverage
Any help would be appreciated!
- SF_Monkey
- October 18, 2019
- Like
- 0
Getting Null Pointer Exception
I am trying to add months to a date field and add that value to the List<Date>. I am getting null pointer exception
Apex Code
I am getting Null Pointer exceptbill.add(newBill). I used system debug statement shows the correct value.
Cant understand how to fix this.
Any help would be aapreciated!
Apex Code
public class stndReduceExcel { public Contingency__c stndReduce{get;set;} public List<Date> bill{get;set;} ApexPages.StandardController controller; public stndReduceExcel(ApexPages.StandardController con){ controller = con; stndReduce = [Select name, Account__c, BILLING_BEGINS_DATE__c, Num_to_Bill__c from Contingency__c where id = :System.currentPagereference().getParameters().get('id')]; Date newbill = stndReduce.BILLING_BEGINS_DATE__c; for(Integer i = 1; i <= stndReduce.Num_to_Bill__c ; i++){ newBill = newBill.addMonths(i); system.debug(newBill); bill.add(newBill); } } }
I am getting Null Pointer exceptbill.add(newBill). I used system debug statement shows the correct value.
Cant understand how to fix this.
Any help would be aapreciated!
- SF_Monkey
- June 24, 2019
- Like
- 0
Getting value of lightning input text in aura:iteration
I have a wrapper class that iterate. I want to get the vlaue of just one text field from the iteration. That field is used to create a new record for a different object.
Lightning component
JS Controller:
Any help would be appreciated
Lightning component
<aura:component controller="billDownCtrl" Implements="flexipage:availableForRecordHome, force:lightningQuickActionWithoutHeader"> <!-- Attributes and handlers--> <aura:attribute name="venList" type='billDownCtrl.wrapper[]'/> <aura:handler name="init" action="{!c.doInIt}" value="{!this}" /> <aura:attribute name="venId" type='string'/> <aura:attribute name="amt" type="Decimal"/> <aura:attribute name="amtList" type="Decimal[]"/> <lightning:card title="Download Cycle "> <section > <table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer " role="grid"> <!--Display the bill download cycle --> <tbody> <aura:iteration items="{!v.venList}" var="ven" indexVar="rowIndex"> <tr> <th scope="row" data-index="{!rowIndex}" > <lightning:formattedNumber value="{!ven.down}" /></th> </tr> <table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer "> <aura:iteration items="{!ven.acc}" var="eng" > <thead> <tr class="slds-text-body_small" role="gridcell"> <th scope="col" style="width:50px"><span class="slds-truncate" role="gridcell">Portal Link</span></th> </tr> </thead> <tbody> <lightning:formattedText linkify="true" value="{!eng.Portal_Link__c}" /> <br/> <!--Display vendor invoices --> <table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer "> <thead> <tr class="slds-text-heading--small"> <th scope="col"><span class="slds-truncate">Vendor Invoice</span></th> <th scope="col"><span class="slds-truncate">Customer</span></th> <th scope="col"><span class="slds-truncate">Login</span></th> <th scope="col"><span class="slds-truncate">Password</span></th> <th scope="col"><span class="slds-truncate">Last Download</span></th> <th scope="col"><span class="slds-truncate">Location Name</span></th> <th scope="col"><span class="slds-truncate">Location Address</span></th> <th scope="col"><span class="slds-truncate">Bill Cycle</span></th> <th scope="col"><span class="slds-truncate">Current Amt Due</span></th> <th scope="col"><span class="slds-truncate">Completed</span></th> </tr> </thead> <aura:iteration items="{!eng.Vendor_Invoices__r}" var="ac"> <tbody> <!--Form for the vendor invoices --> <tr> <td> <th scope="row"><a href="{!'/one/one.app?#/sObject/'+ ac.Id + '/view'}"> <lightning:formattedText value="{!ac.Name}" /></a></th> </td> <td> <lightning:formattedText value="{!ac.Account__r.Name}" /> </td> <td> <lightning:formattedText value="{!ac.Login__c}" /> <br/> <lightning:button iconName="utility:copy_to_clipboard" onclick="{!c.copyInputFieldValue}" label="Copy" value="{!ac.Login__c}"/> </td> <td> <lightning:formattedText value="{!ac.Password__c}" /> <br /> <lightning:button iconName="utility:copy_to_clipboard" onclick="{!c.copyInputFieldValue}" label="Copy" value="{!ac.Password__c}"/> </td> <td> <lightning:formattedDateTime value="{!ac.Last_Download__c}" /> </td> <td> <lightning:formattedText value="{!ac.Location_Name__c}" /> </td> <td> <lightning:formattedText value="{!ac.Location_Address__c}" /> </td> <td> <lightning:formattedNumber value="{!ac.Bill_Cycle__c}" /> </td> <td><lightning:input type="number" aur:id="amtList" value="{!ac.Data_Bill_Benchmark__c}" name="{!rowIndex}" onchange="{!c.getAmt}"/></td> <td><button type="button" onclick="{!c.complete}" name="{!rowIndex}" class="slds-button slds-button--brand" id="{!ac.Id}">Completed</button></td> </tr> </tbody> </aura:iteration> </table> </tbody> </aura:iteration> </table> <!-- End of displaying Vendor Invoice--> </aura:iteration> </tbody> </table> </section> </lightning:card> </aura:component>
JS Controller:
getAmt : function(component, event){ var amtlist = component.find('amtList').get('v.value'); var getIndex = event.getSource().get("v.name"); var form = component.get("v.venList"); var amt = form[getIndex]; alert(amt.amtlist); component.set('v.amt', ''); },
Any help would be appreciated
- SF_Monkey
- May 29, 2019
- Like
- 0
soql query with group clause
I am trying to write a soql quey that is very similar to a summary report. I unsure but I believe that I need to group clause in the query.
This is the result that I am trying to achieve
every field on this table is from the same object. I need to group by download_cycle__c and portal_name__c.
here is what I have been written but i cant get the desired result. I have not even attempted to write the lightning component table for it.
Thanks for the help in advance
This is the result that I am trying to achieve
every field on this table is from the same object. I need to group by download_cycle__c and portal_name__c.
here is what I have been written but i cant get the desired result. I have not even attempted to write the lightning component table for it.
select count(Download_Cycle__c), Name, Last_Download__c, Portal_Name__c, count(Portal_URL__c), Password__c, Login__c, Count(Bill_Cycle__c), Location_Address__c, Location_Name__c from vendor_Invoice__c group by Name, Last_Download__c, Portal_Name__c, Password__c, Login__c, Location_Address__c, Location_Name__c
Thanks for the help in advance
- SF_Monkey
- May 15, 2019
- Like
- 0
iterate child records with aura:component
I am tring to load the child records with aura iterate. The records are loading from soql statement and the parent records are displayed; however, the child records will not load. It is a self-lookup relation with the object.
Any help would be appreciated
<section > <div > <div class="slds-modal__content slds-p-around_medium" > <lightning:accordion allowMultipleSectionsOpen="true" > <table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer "> <div aura:id="conEditForm"> <thead> <tr class="slds-text-heading--small"> <th scope="col"><span class="slds-truncate">Name</span></th> <th scope="col"><span class="slds-truncate">Location Name</span></th> <th scope="col"><span class="slds-truncate">Login</span></th> <th scope="col"><span class="slds-truncate">Password</span></th> <th scope="col"><span class="slds-truncate" style="width:75px">Portal URL</span></th> <th scope="col"><span class="slds-truncate">Active</span></th> <th scope="col"><span class="slds-truncate">Monitored</span></th> <th scope="col"><span class="slds-truncate">Online Access</span></th> <th scope="col"><span class="slds-truncate">Last Download</span></th> <th scope="col"><span class="slds-truncate">Action</span></th> <th scope="col"><span class="slds-truncate">Record</span></th> </tr> </thead> <tbody > <aura:iteration items="{!v.data}" var="vend" indexVar="rowIndex"> <tr> <th scope="row" data-index="{!rowIndex}" onclick="{!c.toggle}" role="gridcell"> <lightning:accordionSection label="{!vend.Name}" /></th> <td><ui:outputText value="{!vend.Location_Name__c}"/></td> <td><ui:outputText value="{!vend.Login__c}"/></td> <td><ui:outputText value="{!vend.Password__c}"/></td> <td><ui:outputText value="{!vend.Portal_URL__c}"/> </td> <td><ui:outputCheckbox value="{!vend.Active_Account__c}"/></td> <td><ui:outputCheckbox value="{!vend.X180_Monitored__c}"/></td> <td><ui:outputCheckbox value="{!vend.Online_Access__c}"/></td> <td><ui:outputDate value="{!vend.Last_Download__c}"/></td> <td><button type="button" onclick="{!c.handleRowAction}" class="slds-button slds-button--neutral slds-float_center" id="{!vend.Id}">Add Child</button></td> <td><a href="{!'/one/one.app?#/sObject/'+ vend.Id + '/view'}"><ui:outputText value="Record Detail"/> </a></td> </tr> <!--Expanded section to display the child vendor invoices --> <aura:if isTrue="{!vend.expanded}"> <table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer "> <thead> <tr class="slds-text-body_small "> <th scope="col" style="width:50px"><span class="slds-truncate">Account #</span></th> <th scope="col" style="width:75px"><span class="slds-truncate">Service Type</span></th> <th scope="col" style="width:75px"><span class="slds-truncate">Aggregate Benchmark</span></th> <th scope="col" style="width:75px"><span class="slds-truncate">Location Name</span></th> </tr> </thead> <aura:iteration items="{!vend.vendor_invoices__r}" var="chil"> <tbody> <tr> <th scope="row" ><ui:outputText value="{!chil.Name}"/></th> <td ><ui:outputText value="{!chil.Service_Type__c}"/></td> <td style="width:75px"><ui:outputCurrency value="{!chil.Aggregate_Benchmark__c}"/></td> <td style="width:75px"><ui:outputText value="{!chil.Location_Name__c}"/></td> </tr> </tbody> </aura:iteration> </table> </aura:if> </aura:iteration> </tbody> </div> </table> </lightning:accordion> </div> </div> </section>
Any help would be appreciated
- SF_Monkey
- April 24, 2019
- Like
- 0
Setting page orientation when VF is exported to excel
I am trying to format excel file that is exported for VisualForce page. I am able to export the data in a table with cell width that I need. For printing, I want to set the page orientation:Landscape and width of the page to fit one page. I am unable to do that. I have two VF pages, both are for the same table but different approach. Any solution in either of the approaches will be helpful
VF 1
VF 2
VF 1
<apex:page controller="accMgrCtrl" id="pg" standardStylesheets="false" contentType="application/vnd.ms-excel#DM-Reached-Last90Days-{!TODAY()}.xls" cache="true" language="en-US"> <head> <style> @page { size:landscape; } </style> </head> <table style="border:1px solid; font-size:16px;"> <tr style="text-align:center; border:1px solid; "> <th>Name</th> <th>Next Follow-Up Date</th> <th>Next Follow-Up Action</th> <th>Primary POC</th> <th>Last DM Reached</th> </tr> <apex:repeat value="{!accList}" var="a"> <tr style="text-align:center; border:1px solid; width:auto; word-wrap: break-word;"> <td><apex:outputLink value="/{!a.id}">{!a.Name}</apex:outputLink></td> <td data-cell-type="date"><apex:outputField value="{!a.NEXT_FOLLOW_UP_DATE__c}"/></td> <td style=" word-wrap: break-word; "><apex:outputField value="{!a.Next_Action_Follow_Up__c}"/></td> <td><apex:outputField value="{!a.Primary_POC__c}"/></td> <td data-cell-type="date"> <apex:repeat value="{!a.Prospecting_Activities__r}" var="t"> <apex:outputField value="{!t.Activity_Date__c }"/> </apex:repeat> </td> </tr> </apex:repeat> </table> </apex:page>
VF 2
<apex:page controller="accMgrCtrl" contentType="application/vnd.ms-excel#DM-Reached-Last90Days-{!TODAY()}.xls" standardStylesheets="false" cache="true" language="en-US"> <apex:outputText value="{!xlsHeader}"/> <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40"> <Styles> <Style ss:ID="s1"> <Alignment/> <Borders/> <Font ss:Bold="1"/> <Interior/> <NumberFormat/> <Protection/> </Style> </Styles> <Worksheet ss:Name="Accounts"> <Table x:FullColumns="5" x:FullRows="1"> <Column ss:Width="170"/> <Column ss:Width="280"/> <Column ss:Width="330"/> <Column ss:Width="330"/> <Column ss:Width="330"/> <Row> <Cell ss:StyleID="s1"><Data ss:Type="String" >Account Name</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Next Follow-Up Date</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Next Follow-Up Action</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Primary POC</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Last DM Reached</Data></Cell> </Row> <apex:repeat value="{!accList}" var="a"> <Row> <Cell><Data ss:Type="String">{!a.name}</Data></Cell> <Cell><Data ss:Type="Date">{!a.NEXT_FOLLOW_UP_DATE__c}</Data></Cell> <Cell><Data ss:Type="String">{!a.Next_Action_Follow_Up__c}</Data></Cell> <Cell><Data ss:Type="String">{!a.Primary_POC__c}</Data></Cell> <apex:repeat value="{!a.Prospecting_Activities__r}" var="t"> <Cell><Data ss:Type="Date">{!t.Activity_Date__c}</Data></Cell> </apex:repeat> </Row> </apex:repeat> </Table> </Worksheet> </Workbook> </apex:page>
- SF_Monkey
- April 16, 2019
- Like
- 0
report api and excel
Hello everyone,
I am very new to API and writing my first API ever. I am trying to extract data from a report and put it in a formatted excel file. It is giving me an error.
Apex class
Error:
Line: 11, Column: 1
System.CalloutException: no protocol: /services/data/v45.0/analytics/reports/00OG00000046KbV
I understand that the endpoint is coming as blank. I looked at the REST API and Reports & Dashoard guide. I cannot find a way to fix this. Is it because of authorization?
Any suggestion would be appreciated!
Thanks!
I am very new to API and writing my first API ever. I am trying to extract data from a report and put it in a formatted excel file. It is giving me an error.
Apex class
public class excelReport { public excelReport(){ Http http = new http(); HttpRequest request = new HttpRequest(); string sessionId = System.UserInfo.getSessionId(); request.setEndpoint('/services/data/v45.0/analytics/reports/00OG00000046KbV'); request.setMethod('GET'); request.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionId()); request.setHeader('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); HttpResponse response = http.send(request); if(response.getStatusCode() == 200){ System.debug(response.getBody()); } } }
Error:
Line: 11, Column: 1
System.CalloutException: no protocol: /services/data/v45.0/analytics/reports/00OG00000046KbV
I understand that the endpoint is coming as blank. I looked at the REST API and Reports & Dashoard guide. I cannot find a way to fix this. Is it because of authorization?
Any suggestion would be appreciated!
Thanks!
- SF_Monkey
- March 26, 2019
- Like
- 0
Export report to an excel template
Hello everyone,
I am trying to figure out a way to export a report or a pre-formatted excel template. Basically, I would like to created a button that user clicks and it export the report or an excel file which formatted or designed that is saved on salesforce server or our local server . It is similar functionality as conga application but we are trying to build an in-house function for our custom needs. I am able to export the report and formated it later. I am new to this so any help would be appreaciated. Any starting points or general process to accomplish this ?
Thanks!
I am trying to figure out a way to export a report or a pre-formatted excel template. Basically, I would like to created a button that user clicks and it export the report or an excel file which formatted or designed that is saved on salesforce server or our local server . It is similar functionality as conga application but we are trying to build an in-house function for our custom needs. I am able to export the report and formated it later. I am new to this so any help would be appreaciated. Any starting points or general process to accomplish this ?
Thanks!
- SF_Monkey
- March 21, 2019
- Like
- 0
Checkbox not showing correct value
I have an apex method where I am comparing two list and updating a field which is a checkbox. On the table, the checbox is showing checked only the last added element to the list. I checked the log and it is working correctly according to it. Thanks!
Apex method
Lightning cmp:
Apex method
List<Prospect__c> props = [select account__c, vertical__c from Prospect__c where account__c = :accId order by name ]; List<vertical__c> verts = [select name, id from vertical__c order by name]; List<vertical__c> upper = new List<vertical__c>(); for(vertical__c m : verts){ Set<String> s = new set<string>(); s.add(m.Id); for(Prospect__c p :props){ if(s.contains(p.Vertical__c)){ m.Included__c = true; } else{ m.Included__c = false; } } upper.add(m); } update upper; return upper;
Lightning cmp:
<table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer " > <div aura:id="conEditForm" > <thead> <tr class="slds-text-heading--small"> <th scope="col"><span class="slds-truncate">Included</span></th> <th scope="col"><span class="slds-truncate">Name</span></th> <th scope="col"><span class="slds-truncate">Add</span></th> <th scope="col"><span class="slds-truncate">Remove</span></th> </tr> </thead> <tbody > <aura:iteration items="{!v.data}" var="conList" > <tr> <th scope="row"><ui:outputCheckbox value="{!conList.Included__c}" aura:id="checker"/></th> <td><a href="{!'/one/one.app?#/sObject/'+ conList.Id + '/view'}"><ui:outputText value="{!conList.Name}"/></a></td> <td><button type="button" onclick="{!c.addVert}" class="slds-button slds-button--success slds-float_center" id="{!conList.Id}">Add</button></td> <td><button type="button" onclick="{!c.delVert}" class="slds-button slds-button--destructive slds-float_center" id="{!conList.Id}">Remove</button></td> </tr> </aura:iteration> </tbody> </div> </table>
- SF_Monkey
- March 13, 2019
- Like
- 0
write test class for wrapper and else statement
Hey,
I am having issues getting the converage for the apex class (newCom). This class gives users a list of record and they can click any number of cases to attach them to the parent (Billing_Change_Form__c). I am getting 67% coverage but I am not able to cover the else statement lines.
My apex class (newCom)
My test class
The uncovered lines in the picture are where the users are click and select the cases.
Any help will be appreciated.
Thanks!
I am having issues getting the converage for the apex class (newCom). This class gives users a list of record and they can click any number of cases to attach them to the parent (Billing_Change_Form__c). I am getting 67% coverage but I am not able to cover the else statement lines.
My apex class (newCom)
// Controller for Billing Form Button on Account public with sharing class newCom { //Declare variables public account acc{get;set;} public Billing_Change_Form__c comBill {get;set;} id acID = System.currentPagereference().getParameters().get('id'); public list<conCase> caseList{get;set;} public boolean bool{get;set;} public set<id> caseIds{get;set;} ApexPages.StandardController controller; public string result{get;set;} //Contructor public newCom (ApexPages.StandardController con){ comBill = new Billing_change_form__c(); id acID = System.currentPagereference().getParameters().get('id'); comBill.RecordTypeId = '0124A000001lBu9QAE'; comBill.Account__c = acId; controller = con; caseList = new list<conCase>(); bool = false; caseIds = new Set<id>(); } //Event on clicking the checkbox public void inIt(){ List<Contingency__c> selectedCase = new list<Contingency__c>(); for(conCase conObj : caseList){ if(conObj.check != False) { system.debug('conObj.con'+ conObj.con); selectedCase.add(conObj.con); caseIds.add(conObj.con.id); bool = true; } If(conObj.check != true) {caseIds.remove(conObj.con.id); } } } //Displaying the case findings records public List<conCase> getShow(){ caseList = new list <conCase> (); for(Contingency__c coObj : [Select id, name,billing_type__c, report_description__c, discovery_amount__c, billing_begins_date__c, contingency__c, VENDOR_INVOICE__r.Account_del__r.Id from Contingency__c where (VENDOR_INVOICE__r.Account_del__r.Id = :acID) AND (contingency__c like 'IN BILLING') ORDER BY NAME]) {caseList.add(new conCase(coObj, Bool));} return caseList; } //Event on saving public PageReference comInsert(){ // newBill.RecordTypeId = '0124A000001lBu9QAE'; // Inserting the new record list<Contingency__c> noSelectedCase = [select id, name, bill_form__c from Contingency__c where id = :caseIds ]; if(noSelectedCase.size()<1){ combill.adderror('Please select a case for this form'); ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, ' Please select a case for this form' )); return null; } else{ comBill.name = 'Nada'; comBill.account__c = acID; insert comBill; result = comBill.Id; //Inserting Case Findings list<Contingency__c> updateSelectedCase = new list<Contingency__c>(); for(Contingency__c co:[select id, name, bill_form__c from Contingency__c where id = :caseIds ]) {co.bill_form__c =result ; updateSelectedCase.add(co);} update updateSelectedCase; //Redirecting Page to new record created PageReference rePage = new PageReference('/'+result); rePage.setRedirect(true); rePage.getParameters().put('id',controller.getId()); return repage;} } //Event on hitting the cancel button public PageReference noBill(){ comBill.Reason_for_Removal__c = 'Our Error'; comBill.Total_Adjustment_Amount__c = 1; comBill.Name = 'Nada'; PageReference pageRef = new PageReference('/'+acId); pageRef.setRedirect(true); return pageRef; } //Wrapper class for the selected records public class conCase{ public contingency__c con{get;set;} public boolean check{get;set;} public conCase(contingency__c c, boolean boo){ con = c; check = boo; } } }
My test class
public static testMethod void btnTestCom(){ Account accTest = new Account(); accTest.Name = 'Test Account'; insert accTest; Account accTest2 = new Account(); accTest2.Name = 'Test Account2'; insert accTest2; Account_number__c venTest = new Account_Number__c(); venTest.Name = 'Test Ven'; venTest.Account_del__c = accTest.id; insert venTest; Account_number__c venTest2 = new Account_Number__c(); venTest2.Name = 'Test Ven2'; venTest2.Account_del__c = accTest2.id; insert venTest2; Billing_Change_form__c testBill2 = new Billing_Change_Form__c(); testBill2.Name = 'Test name2'; testBill2.Reason_for_Removal__c = 'Term Completed'; testbill2.Reason_what_why__c = 'nada'; testbill2.Total_Adjustment_Amount__c = 123; insert testBill2; Billing_Change_form__c testBill = new Billing_Change_Form__c(); testBill.Name = 'Test name'; testBill.Reason_for_Removal__c = 'Term Completed'; testbill.Reason_what_why__c = 'nada'; testbill.Total_Adjustment_Amount__c = 123; insert testBill; Contingency__c caseTest = new Contingency__c(); caseTest.Name = 'test Case'; caseTest.Contingency__c = 'IN BILLING'; caseTest.vendor_invoice__c = venTest.id; insert caseTest; Contingency__c caseTest2 = new Contingency__c(); caseTest2.Name = 'test Case2'; caseTest2.Contingency__c = 'IN BILLING'; caseTest2.Bill_form__c = testBill.Id ; caseTest2.vendor_invoice__c = venTest2.id; insert caseTest2; Set<id> caseIds = new Set<id>(); caseIds.add(caseTest.id); caseIds.add(caseTest2.id); Test.startTest(); PageReference pageRef = Page.accBill; // Add your VF page Name here pageRef.getParameters().put('id', String.valueOf(testBill.Id)); Test.setCurrentPage(pageRef); ApexPages.StandardController sc = new ApexPages.StandardController(testBill); newCom testAccPlan = new newCom(sc); newCre.conCase wrap1 = new newCre.conCase(caseTest2, false); wrap1.check = true; wrap1.con = caseTest2; list<newCre.conCase> caseList = new list<newCre.conCase>(); caseList.add(wrap); caseList.add(wrap1); testAccPlan.inIt(); testAccPlan.getShow(); testAccPlan.comInsert(); testAccPlan.noBill(); test.stopTest(); }
The uncovered lines in the picture are where the users are click and select the cases.
Any help will be appreciated.
Thanks!
- SF_Monkey
- February 27, 2019
- Like
- 0
pass recordId to another lightning component using lightning:navigation
I having issues with passing the recordId from acapBtn.cmp to acapChecklist.com.
I have interface lightning:isUrlAddressable on both the component. It is navigating to the right component; however, it is not passing the recordId value to the acapChecklist.cmp.
Thanks!
acapBtn.cmp <lightning:navigation aura:id="navigationService"/> acapBtnController var recordId = component.get("v.recordId"); component.find("navigationService").navigate({ type: "standard__component", attributes: { componentName: "c__acapChecklist" }, state: { recordId: recordId } });
I have interface lightning:isUrlAddressable on both the component. It is navigating to the right component; however, it is not passing the recordId value to the acapChecklist.cmp.
Thanks!
- SF_Monkey
- February 20, 2019
- Like
- 0
assign list of string to name of list of an object
I am trying to insert multiple records with assigned list of names and accountid lookup. The list of string contains the name of the record then assign each of those records with accountID. I guess that I have to use a for loop; however, I am unable to execute this. Any help would be appreciated thanks!
@AuraEnabled public static void stackup(id accountid, List<String> itemsValue){ List<Acap_Checklist__c> nList = new List<Acap_Checklist__c>(); for(Acap_Checklist__c n : nList){ n.account__c = accountid; for(String c : itemsValue){ n.Name = c; } nList.add(n); } insert nList; }
- SF_Monkey
- February 20, 2019
- Like
- 0
Attach file to VF page and show it as a related list
I am trying to add an attachment to a VF page on a custom object. I want those attached files to appear as related files on the record. The page creates a new record, give list of cases to attach with it (Works Well) and option of three attachments (problem). When Save button is hit, new record and cases are added; however, the attachments do not show up in the related files.
I am aware that as of 2016, Salesforce convert all of the attachments as files. I have read some articles about ContentVersion and ContentDocument.
I am unable to understand how to put it into practice or how to use it in this context. My futile attempt is written in the code below. Any help will be appreciated.
Thanks!
VisualForce Page:
My controller extension:
I am aware that as of 2016, Salesforce convert all of the attachments as files. I have read some articles about ContentVersion and ContentDocument.
I am unable to understand how to put it into practice or how to use it in this context. My futile attempt is written in the code below. Any help will be appreciated.
Thanks!
VisualForce Page:
<apex:page standardController="Account" extensions="newCom" > <script> function closeWindow(){ window.opener.location.href="/{!$CurrentPage.parameters.id}" } var $j = jQuery.noConflict(); function getValues() { var v1 = $j('.value1').val(); if(typeof v1 != 'undefined') sendValues(v1); } </script> <!--Page Header --> <apex:sectionHeader title="New Bill Complete Form"/> <apex:form html-novalidate="novalidate"> <apex:actionFunction name="sendValues" reRender="render"> <apex:param name="value1" value="" assignTo="{!value1}" /> </apex:actionFunction> <!--Page block to enter the new information --> <apex:pageBlock title="New Billing Complete Form" mode="edit"> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!comInsert}"/> <apex:commandButton value="Cancel" action="{!noBill}" immediate="true" /> </apex:pageBlockButtons> <apex:pageBlockSection title="Information" > <apex:outputField label="Account" value="{!comBill.Account__c}" /> <apex:outputField label="Record Type" value="{!comBill.RecordTypeID}"/> <apex:inputField label="Reason for Removal" value="{!comBill.Reason_for_Removal__c}" onchange="getValues()" required="true"/><br/> <apex:inputField label="Total Adjustment Amount" value="{!comBill.Total_Adjustment_Amount__c}" required="true"/> <apex:inputField label="Notes" value="{!comBill.Notes__c}" style="width: 360px; height: 100px" /> </apex:pageBlockSection> <apex:pageBlockSection title="Actions To Complete After Final Approval"> <apex:inputCheckBox label="Backups Moved To Bill Complete" value="{!comBill.Backups_Moved_To_Bill_Complete__c}"/> <apex:inputField label="Billing Status" value="{!comBill.Billing_Status__c}"/> <apex:inputCheckbox label="Credit Memo Created" value="{!comBill.Credit_Memo_Created__c}"/> <br/> <apex:inputCheckbox label="Update Futures" value="{!comBill.Update_Futures__c}"/> </apex:pageBlockSection> <!-- FOR THE CASE FINDING SECTION --> <apex:pageBlockSection title="Case Findings"> <apex:pageBlockTable value="{!show}" var="e" title="show" style="width: 1450px"> <apex:column > <apex:inputCheckbox value="{!e.check}" /> <apex:actionSupport event="onclick" action="{!inIt}" rerender="none"/> </apex:column> <apex:column value="{!e.con.Name}"/> <apex:column value="{!e.con.DISCOVERY_AMOUNT__c}"/> <apex:column value="{!e.con.BILLING_BEGINS_DATE__c}"/> <apex:column value="{!e.con.REPORT_DESCRIPTION__c}"/> <apex:column value="{!e.con.CONTINGENCY__c}"/> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> </apex:form> <!-- FOR THE ATTACHMENT SECTION --> <apex:form > <apex:pageBlock > <apex:pageBlockSection title="Attachment"> <apex:inputFile value="{!attachment1.body}" fileName="{!attachment1.name}"/> <br/> <apex:inputFile value="{!attachment2.body}" fileName="{!attachment2.name}"/> <br/> <apex:inputFile value="{!attachment3.body}" fileName="{!attachment3.name}"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
My controller extension:
public with sharing class newCom { //Declare variables public account acc{get;set;} public Billing_Change_Form__c comBill {get;set;} id acID = System.currentPagereference().getParameters().get('id'); public list<conCase> caseList{get;set;} public boolean bool{get;set;} public set<id> caseIds{get;set;} ApexPages.StandardController controller; public string result{get;set;} public Attachment attachment1 { get; set; } public Attachment attachment2 { get; set; } public Attachment attachment3 { get; set; } //Contructor public newCom (ApexPages.StandardController con){ comBill = new Billing_change_form__c(); id acID = System.currentPagereference().getParameters().get('id'); comBill.RecordTypeId = '0124A000001lBu9QAE'; comBill.Account__c = acId; controller = con; caseList = new list<conCase>(); bool = false; caseIds = new Set<id>(); attachment1 = new Attachment(); attachment2 = new Attachment(); attachment3 = new Attachment(); } //Event on clicking the checkbox public void inIt(){ List<Contingency__c> selectedCase = new list<Contingency__c>(); for(conCase conObj : caseList){ if(conObj.check != False) { system.debug('conObj.con'+ conObj.con); selectedCase.add(conObj.con); caseIds.add(conObj.con.id); bool = true; } If(conObj.check != true) {caseIds.remove(conObj.con.id); } } } //Displaying the case findings records public List<conCase> getShow(){ caseList = new list <conCase> (); for(Contingency__c coObj : [Select id, name,billing_type__c, report_description__c, discovery_amount__c, billing_begins_date__c, contingency__c, VENDOR_INVOICE__r.Account_del__r.Id from Contingency__c where (VENDOR_INVOICE__r.Account_del__r.Id = :acID) AND (contingency__c like 'IN BILLING') ORDER BY NAME]) {caseList.add(new conCase(coObj, Bool));} return caseList; } //Event on saving public PageReference comInsert(){ // newBill.RecordTypeId = '0124A000001lBu9QAE'; // Inserting the new record comBill.name = 'Nada'; comBill.account__c = acID; insert comBill; result = comBill.Id; //Inserting Case Findings list<Contingency__c> updateSelectedCase = new list<Contingency__c>(); for(Contingency__c co:[select id, name, bill_form__c from Contingency__c where id = :caseIds ]) {co.bill_form__c =result ; updateSelectedCase.add(co);} update updateSelectedCase; //Adding the attachment to the record List<Attachment> toInsert = new List<Attachment>(); if(attachment1.Name != null) { attachment1.ParentId = result; toInsert.add(attachment1); } if(attachment2.Name != null) { attachment2.ParentId = result; toInsert.add(attachment2); } if(attachment3.Name != null) { attachment3.ParentId = result; toInsert.add(attachment3); } if(toInsert.size() > 0) insert toInsert; //Redirecting Page to new record created PageReference rePage = new PageReference('/'+result); rePage.setRedirect(true); rePage.getParameters().put('id',controller.getId()); return repage; } //Event on hitting the cancel button public PageReference noBill(){ comBill.Reason_for_Removal__c = 'Our Error'; comBill.Total_Adjustment_Amount__c = 1; comBill.Name = 'Nada'; PageReference pageRef = new PageReference('/'+acId); pageRef.setRedirect(true); return pageRef; } //Wrapper class for the selected records public class conCase{ public contingency__c con{get;set;} public boolean check{get;set;} public conCase(contingency__c c, boolean boo){ con = c; check = boo; } } }
- SF_Monkey
- January 25, 2019
- Like
- 0
How to write a test class for multi select lookup page
I am having a super hard time in writing a test class. The extension lets a user select multiple records from child (Contingency__c) and add to the related list of parent (Billing_Change_form__c) where the account is the same. It contains a wrapper class. I have no idea how to get any coverage.
This is the test class that I have come up with so far:
@isTest
public class bcfTest {
public static testMethod void adBill(){
Billing_Change_form__c testBill = new Billing_Change_Form__c();
testBill.Name = 'Test name';
insert testBill;
Billing_Change_form__c testBill2 = new Billing_Change_Form__c();
testBill2.Name = 'Test name2';
insert testBill2;
Contingency__c caseTest = new Contingency__c();
caseTest.Name = 'test Case';
caseTest.Contingency__c = 'IN BILLING';
caseTest.VENDOR_INVOICE__r.Account_del__r.id='1234';
insert caseTest;
Contingency__c caseTest2 = new Contingency__c();
caseTest2.Name = 'test Case2';
caseTest2.Contingency__c = 'IN BILLING';
caseTest2.VENDOR_INVOICE__r.Account_del__r.id='5678';
insert caseTest2;
Account accTest = new Account();
accTest.Name = 'Test Account';
insert accTest;
Test.startTest();
PageReference pageRef = Page.bcTest; // Add your VF page Name here
pageRef.getParameters().put('id', String.valueOf(testBill.Id));
Test.setCurrentPage(pageRef);
List<wrapperCase> wrapList = new List<wrapperCase>();
List<Contingency__c> selCase = new List<Contingency__c>();
for(Contingency__c b : [Select id, name,
contingency__c, VENDOR_INVOICE__r.Account_del__r.Id from Contingency__c
where (VENDOR_INVOICE__r.Account_del__r.Id = :accTest.Id) ]){
wrapList.add(New wrapperCase(b));
}
for(wrapperCase WATest: wrapList){
WATest.check = true;
}
System.assertEquals(testBill.Id, caseTest.Bill_Form__c);
System.assertEquals('Test name',testBill.Name);
System.assertEquals('IN BILLING', caseTest.CONTINGENCY__c);
test.stopTest();
}
public class wrapperCase{
public contingency__c con{get;set;}
public boolean check{get;set;}
public wrapperCase(contingency__c c){
con = c;
check = false;
}
}
}
My controller extension:
public with sharing class test2 {
//Declare varialbles
public string lookup{get;set;}
public list<conCase> caseList{get;set;}
public boolean allbool{get;set;}
public string inputValue{get;set;}
public boolean bool{get;set;}
public set<id> caseIds{get;set;}
Billing_Change_form__c[] accID = [Select account__c from Billing_Change_Form__c where
id = :System.currentPagereference().getParameters().get('id')];
ApexPages.StandardController controller;
//Constructor
public test2(ApexPages.StandardController con){
controller = con;
caseList = new list<conCase>();
bool = false;
caseIds = new Set<id>();
}
//Event on clicking the checkbox
public void inIt(){
List<Contingency__c> selectedCase = new list<Contingency__c>();
lookUp = '';
for(conCase conObj : caseList){
if(conObj.check != False){
system.debug('conObj.con'+ conObj.con);
selectedCase.add(conObj.con);
lookUp += conObj.con.name + ', ';
system.debug('lookup:'+ lookup);
caseIds.add(conObj.con.id);
bool = true;
}
If(conObj.check != true){
caseIds.remove(conObj.con.id); }
}
}
//Displaying the records
public List<conCase> getShow(){
caseList = new list <conCase> ();
for(Contingency__c coObj : [Select id, name,billing_type__c, report_description__c, discovery_amount__c,
billing_begins_date__c, contingency__c, VENDOR_INVOICE__r.Account_del__r.Id from Contingency__c
where (VENDOR_INVOICE__r.Account_del__r.Id = :accID[0].Account__c) AND (Bill_form__c = null)])
{
caseList.add(new conCase(coObj, Bool));
}
return caseList;
}
//Event on saving the selected records
public PageReference mySave(){
list<Contingency__c> updateSelectedCase = new list<Contingency__c>();
id billId = ApexPages.currentPage().getparameters().get('id');
System.debug('Bill ID is' + billID);
for(Contingency__c co:[select id, name, bill_form__c from Contingency__c where id = :caseIds ]){
co.bill_form__c = billId;
updateSelectedCase.add(co);
}
update updateSelectedCase;
return null;
}
//Event When the cancel button is hit
public void closePopup(){
bool = false;
}
public void add(){
bool = true;
}
//Wrapper class for the selected records
public class conCase{
public contingency__c con{get;set;}
public boolean check{get;set;}
public conCase(contingency__c c, boolean boo){
con = c;
check = boo;
}
}
}
My visualforce Page:
<apex:page showHeader="False" standardController="Billing_Change_Form__c" extensions="test2">
<script>
function closeWindow(){
window.opener.location.href="/{!$CurrentPage.parameters.id}";
window.top.close();
}
</script>
<apex:form >
<apex:PageBlock title="CaseFindings" id="counter">
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!mySave}" onComplete="closeWindow();"/>
<apex:commandButton value="Cancel" onclick="window.top.close();" immediate="true" action="{!closePopup}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!show}" var="e" title="show">
<apex:column >
<apex:inputCheckbox value="{!e.check}" />
<apex:actionSupport event="onclick" action="{!inIt}" rerender="none"/>
</apex:column>
<apex:column value="{!e.con.Name}"/>
<apex:column value="{!e.con.DISCOVERY_AMOUNT__c}"/>
<apex:column value="{!e.con.BILLING_BEGINS_DATE__c}"/>
<apex:column value="{!e.con.REPORT_DESCRIPTION__c}"/>
<apex:column value="{!e.con.CONTINGENCY__c}"/>
</apex:pageBlockTable>
</apex:PageBlock>
</apex:form>
</apex:page>
Hoping to get standard 75% coverage. If anyone can help me with it, I would really appreciate it! Thanks!
This is the test class that I have come up with so far:
@isTest
public class bcfTest {
public static testMethod void adBill(){
Billing_Change_form__c testBill = new Billing_Change_Form__c();
testBill.Name = 'Test name';
insert testBill;
Billing_Change_form__c testBill2 = new Billing_Change_Form__c();
testBill2.Name = 'Test name2';
insert testBill2;
Contingency__c caseTest = new Contingency__c();
caseTest.Name = 'test Case';
caseTest.Contingency__c = 'IN BILLING';
caseTest.VENDOR_INVOICE__r.Account_del__r.id='1234';
insert caseTest;
Contingency__c caseTest2 = new Contingency__c();
caseTest2.Name = 'test Case2';
caseTest2.Contingency__c = 'IN BILLING';
caseTest2.VENDOR_INVOICE__r.Account_del__r.id='5678';
insert caseTest2;
Account accTest = new Account();
accTest.Name = 'Test Account';
insert accTest;
Test.startTest();
PageReference pageRef = Page.bcTest; // Add your VF page Name here
pageRef.getParameters().put('id', String.valueOf(testBill.Id));
Test.setCurrentPage(pageRef);
List<wrapperCase> wrapList = new List<wrapperCase>();
List<Contingency__c> selCase = new List<Contingency__c>();
for(Contingency__c b : [Select id, name,
contingency__c, VENDOR_INVOICE__r.Account_del__r.Id from Contingency__c
where (VENDOR_INVOICE__r.Account_del__r.Id = :accTest.Id) ]){
wrapList.add(New wrapperCase(b));
}
for(wrapperCase WATest: wrapList){
WATest.check = true;
}
System.assertEquals(testBill.Id, caseTest.Bill_Form__c);
System.assertEquals('Test name',testBill.Name);
System.assertEquals('IN BILLING', caseTest.CONTINGENCY__c);
test.stopTest();
}
public class wrapperCase{
public contingency__c con{get;set;}
public boolean check{get;set;}
public wrapperCase(contingency__c c){
con = c;
check = false;
}
}
}
My controller extension:
public with sharing class test2 {
//Declare varialbles
public string lookup{get;set;}
public list<conCase> caseList{get;set;}
public boolean allbool{get;set;}
public string inputValue{get;set;}
public boolean bool{get;set;}
public set<id> caseIds{get;set;}
Billing_Change_form__c[] accID = [Select account__c from Billing_Change_Form__c where
id = :System.currentPagereference().getParameters().get('id')];
ApexPages.StandardController controller;
//Constructor
public test2(ApexPages.StandardController con){
controller = con;
caseList = new list<conCase>();
bool = false;
caseIds = new Set<id>();
}
//Event on clicking the checkbox
public void inIt(){
List<Contingency__c> selectedCase = new list<Contingency__c>();
lookUp = '';
for(conCase conObj : caseList){
if(conObj.check != False){
system.debug('conObj.con'+ conObj.con);
selectedCase.add(conObj.con);
lookUp += conObj.con.name + ', ';
system.debug('lookup:'+ lookup);
caseIds.add(conObj.con.id);
bool = true;
}
If(conObj.check != true){
caseIds.remove(conObj.con.id); }
}
}
//Displaying the records
public List<conCase> getShow(){
caseList = new list <conCase> ();
for(Contingency__c coObj : [Select id, name,billing_type__c, report_description__c, discovery_amount__c,
billing_begins_date__c, contingency__c, VENDOR_INVOICE__r.Account_del__r.Id from Contingency__c
where (VENDOR_INVOICE__r.Account_del__r.Id = :accID[0].Account__c) AND (Bill_form__c = null)])
{
caseList.add(new conCase(coObj, Bool));
}
return caseList;
}
//Event on saving the selected records
public PageReference mySave(){
list<Contingency__c> updateSelectedCase = new list<Contingency__c>();
id billId = ApexPages.currentPage().getparameters().get('id');
System.debug('Bill ID is' + billID);
for(Contingency__c co:[select id, name, bill_form__c from Contingency__c where id = :caseIds ]){
co.bill_form__c = billId;
updateSelectedCase.add(co);
}
update updateSelectedCase;
return null;
}
//Event When the cancel button is hit
public void closePopup(){
bool = false;
}
public void add(){
bool = true;
}
//Wrapper class for the selected records
public class conCase{
public contingency__c con{get;set;}
public boolean check{get;set;}
public conCase(contingency__c c, boolean boo){
con = c;
check = boo;
}
}
}
My visualforce Page:
<apex:page showHeader="False" standardController="Billing_Change_Form__c" extensions="test2">
<script>
function closeWindow(){
window.opener.location.href="/{!$CurrentPage.parameters.id}";
window.top.close();
}
</script>
<apex:form >
<apex:PageBlock title="CaseFindings" id="counter">
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!mySave}" onComplete="closeWindow();"/>
<apex:commandButton value="Cancel" onclick="window.top.close();" immediate="true" action="{!closePopup}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!show}" var="e" title="show">
<apex:column >
<apex:inputCheckbox value="{!e.check}" />
<apex:actionSupport event="onclick" action="{!inIt}" rerender="none"/>
</apex:column>
<apex:column value="{!e.con.Name}"/>
<apex:column value="{!e.con.DISCOVERY_AMOUNT__c}"/>
<apex:column value="{!e.con.BILLING_BEGINS_DATE__c}"/>
<apex:column value="{!e.con.REPORT_DESCRIPTION__c}"/>
<apex:column value="{!e.con.CONTINGENCY__c}"/>
</apex:pageBlockTable>
</apex:PageBlock>
</apex:form>
</apex:page>
Hoping to get standard 75% coverage. If anyone can help me with it, I would really appreciate it! Thanks!
- SF_Monkey
- January 16, 2019
- Like
- 0
how to display related list as a custom field
Is there any way to display related list as a field. Isntead of displaying it in a section, can I display as a custome field to show those enteries
- SF_Monkey
- January 15, 2019
- Like
- 0
trigger test coverage
I have trying to get atleast the passing coverage for the trigger. Trigger is working fine but I am being able to get the test coverage. It would capture the oldMap and newMap values in the test
Trigger:
Test
Coverage
Any help would be appreciated!
Trigger:
trigger allAccTrigger on Account (before update) { if(trigger.isUpdate){ if(trigger.isBefore){ if(checkRecursive.runOnce()){ List<Account> accVert = new List<Account>(); List<vendor_invoice__c> ven = new List<Vendor_Invoice__c>(); for( Id accountId : Trigger.newMap.keySet() ){ //Update the coordination checkbox after approval if(trigger.oldMap.get(accountId).Coordination_Complete__c != trigger.newMap.get(accountId).Coordination_Complete__c ){ List<Processing_Checklist__c> prop = [select name from Processing_Checklist__c where account__c = :accountId AND name Like 'Coordination List Completed']; prop[0].Completed__c = true; update prop; } if(trigger.oldMap.get(accountId).RecordTypeId != trigger.newMap.get(accountId).RecordTypeId){ List<Account> accRecType = [select RecordTypeId from account where id = :accountId]; //Check if all the vendor invoices have auditors before converting to contingency if(trigger.newMap.get(accountId).RecordtypeId == '0120h000000MclWAAS'){ for(Vendor_Invoice__c v : [select name, id from vendor_invoice__c where account__c = :accountId AND Auditor_Assignment__c = null]){ ven.add(v); } if(ven.size()> 0){ Trigger.new[0].addError('Please assign auditor to ALL related vendor invoices'); } } //Checking to see if account moved to ACAP record type and deleting everything is vertical for(Account ac : accRecType){ if(ac.RecordTypeId == '0120h000000YQmIAAW'){ accVert.add(ac); } } } } //Getting all the verticals and navigation items to delete after the record is moved to ACAP If(accVert.size() > 0) {List<Prospect__c> props = [select id from Prospect__c where account__c IN :accVert]; List<Navigate_List__c> navList = [select id from Navigate_List__c where account__c IN :accVert]; delete props; delete navList; } } } } }
Test
@isTest public class accTriggerTest { public static testMethod void casTrig(){ Account accTest = new Account(); accTest.Name = 'Test Account'; accTest.Federal_Tax_Exempted__c = true; accTest.State_Tax_Exempted__c = false; accTest.Coordination_Complete__c = false; accTest.Company_Code__c = 'ads'; accTest.RecordTypeId = '0120h000000YQWeAAO'; insert accTest; Opportunity opp = new opportunity(); opp.AccountId = accTest.id; opp.Name = 'trying'; opp.StageName = 'ACAP'; opp.Estimated_Bill_Volume__c = 100; opp.CloseDate = Date.newInstance(2020, 12, 9); opp.Business_Development_Manager__c = UserInfo.getUserId(); opp.Business_Development_Rep__c = UserInfo.getUserId(); opp.RecordTypeId = '0120h000000YQVlAAO'; opp.Credit_Shared__c = 10; opp.Saving_Shared__c = 20; insert opp; Vendor_Information__c venInfo = new Vendor_Information__c(); venInfo.name = 'tester'; venInfo.Abbreviated_Name__c = 'abc'; venInfo.Phone__c = '123456789'; insert venInfo; Vendor_Invoice__c venIn = new Vendor_Invoice__c(); venIn.Account_Number__c = 'fw df42r qe'; venIn.Account__c = accTest.Id; venIn.Vendor_Information__c = venInfo.id; venIn.Federal_Tax_Exempted__c = true; venIn.State_Tax_Exempted__c = false; venIn.Auditor_Assignment__c = UserInfo.getUserId(); insert venIn; Account_Survey__c sur = new Account_Survey__c(); sur.Account__c = accTest.id; insert sur; Case_Finding__c cas = new Case_Finding__c(); cas.Name = 'try it'; cas.Service_Type__c = 'Data'; cas.Case_Date__c = Date.newInstance(2020, 12, 9); cas.Months_To_Bill__c = 12; cas.Vendor_Invoice__c = venIn.id; cas.RecordTypeId = '0120h000000YQPxAAO'; cas.Case_Status__c = 'Active'; insert cas; Case_Finding__c cas1 = new Case_Finding__c(); cas1.Name = 'try it'; cas1.Service_Type__c = 'Data'; cas1.Case_Date__c = Date.newInstance(2020, 12, 9); cas1.Months_To_Bill__c = 12; cas1.Vendor_Invoice__c = venIn.id; cas1.RecordTypeId = '0120h000000i9oWAAQ'; cas1.Case_Status__c = 'Active'; insert cas1; List<Case_Finding__c> cList = new List<Case_Finding__c>(); cList.add(cas); cList.add(cas1); Processing_Checklist__c pro1 = new Processing_Checklist__c(); pro1.Account__c = accTest.id; pro1.Name = 'Coordination List Completed'; pro1.Notes__c = 'i really do not want to write the entire thing so i am going to end it here'; pro1.Completed__c = false; insert pro1; Acap_Checklist__c pro = new Acap_Checklist__c(); pro.Account__c = accTest.id; pro.Name = 'i dont know it yet'; pro.Notes__c = 'i really do not want to write the entire thing so i am going to end it here'; pro.Completed__c = false; insert pro; accTest.RecordTypeId = '0120h000000YQmIAAW'; accTest.Coordination_Complete__c = true; update accTest; } public static testMethod void casTrig1(){ Account accTest = new Account(); accTest.Name = 'Test Account'; accTest.Federal_Tax_Exempted__c = true; accTest.State_Tax_Exempted__c = false; accTest.Coordination_Complete__c = false; accTest.Company_Code__c = 'er'; insert accTest; opportunity opp = new opportunity(); opp.AccountId = accTest.id; opp.Name = 'trying'; opp.StageName = 'ACAP'; opp.Estimated_Bill_Volume__c = 100; opp.CloseDate = Date.newInstance(2020, 12, 9); opp.Business_Development_Manager__c = UserInfo.getUserId(); opp.Business_Development_Rep__c = UserInfo.getUserId(); opp.RecordTypeId = '0120h000000YQVlAAO'; opp.Credit_Shared__c = 10; opp.Saving_Shared__c = 20; insert opp; Vendor_Information__c venInfo = new Vendor_Information__c(); venInfo.name = 'tester'; venInfo.Abbreviated_Name__c = 'abc'; venInfo.Phone__c = '123456789'; insert venInfo; Vendor_Invoice__c venIn = new Vendor_Invoice__c(); venIn.Account_Number__c = 'fw df42r qe'; venIn.Account__c = accTest.Id; venIn.Vendor_Information__c = venInfo.id; venIn.Federal_Tax_Exempted__c = true; venIn.State_Tax_Exempted__c = false; insert venIn; Account_Survey__c sur = new Account_Survey__c(); sur.Account__c = accTest.id; insert sur; Case_Finding__c cas = new Case_Finding__c(); cas.Name = 'try it'; cas.Service_Type__c = 'LOCAL'; cas.Case_Date__c = Date.newInstance(2020, 12, 9); cas.Months_To_Bill__c = 12; cas.Vendor_Invoice__c = venIn.id; cas.RecordTypeId = '0120h000000YQPxAAO'; cas.Case_Status__c = 'Active'; insert cas; Test.startTest(); try{ accTest.RecordTypeId = '0120h000000MclWAAS'; update accTest; system.assert(true, 'Please assign auditor to ALL related vendor invoices');} catch(exception ex){ Boolean expectedExceptionThrown = ex.getMessage().contains('Script-thrown exception') ? true : false; System.assertEquals(expectedExceptionThrown, false); } Test.stopTest(); } }
Coverage
Any help would be appreciated!
- SF_Monkey
- October 18, 2019
- Like
- 0
Getting value of lightning input text in aura:iteration
I have a wrapper class that iterate. I want to get the vlaue of just one text field from the iteration. That field is used to create a new record for a different object.
Lightning component
JS Controller:
Any help would be appreciated
Lightning component
<aura:component controller="billDownCtrl" Implements="flexipage:availableForRecordHome, force:lightningQuickActionWithoutHeader"> <!-- Attributes and handlers--> <aura:attribute name="venList" type='billDownCtrl.wrapper[]'/> <aura:handler name="init" action="{!c.doInIt}" value="{!this}" /> <aura:attribute name="venId" type='string'/> <aura:attribute name="amt" type="Decimal"/> <aura:attribute name="amtList" type="Decimal[]"/> <lightning:card title="Download Cycle "> <section > <table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer " role="grid"> <!--Display the bill download cycle --> <tbody> <aura:iteration items="{!v.venList}" var="ven" indexVar="rowIndex"> <tr> <th scope="row" data-index="{!rowIndex}" > <lightning:formattedNumber value="{!ven.down}" /></th> </tr> <table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer "> <aura:iteration items="{!ven.acc}" var="eng" > <thead> <tr class="slds-text-body_small" role="gridcell"> <th scope="col" style="width:50px"><span class="slds-truncate" role="gridcell">Portal Link</span></th> </tr> </thead> <tbody> <lightning:formattedText linkify="true" value="{!eng.Portal_Link__c}" /> <br/> <!--Display vendor invoices --> <table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer "> <thead> <tr class="slds-text-heading--small"> <th scope="col"><span class="slds-truncate">Vendor Invoice</span></th> <th scope="col"><span class="slds-truncate">Customer</span></th> <th scope="col"><span class="slds-truncate">Login</span></th> <th scope="col"><span class="slds-truncate">Password</span></th> <th scope="col"><span class="slds-truncate">Last Download</span></th> <th scope="col"><span class="slds-truncate">Location Name</span></th> <th scope="col"><span class="slds-truncate">Location Address</span></th> <th scope="col"><span class="slds-truncate">Bill Cycle</span></th> <th scope="col"><span class="slds-truncate">Current Amt Due</span></th> <th scope="col"><span class="slds-truncate">Completed</span></th> </tr> </thead> <aura:iteration items="{!eng.Vendor_Invoices__r}" var="ac"> <tbody> <!--Form for the vendor invoices --> <tr> <td> <th scope="row"><a href="{!'/one/one.app?#/sObject/'+ ac.Id + '/view'}"> <lightning:formattedText value="{!ac.Name}" /></a></th> </td> <td> <lightning:formattedText value="{!ac.Account__r.Name}" /> </td> <td> <lightning:formattedText value="{!ac.Login__c}" /> <br/> <lightning:button iconName="utility:copy_to_clipboard" onclick="{!c.copyInputFieldValue}" label="Copy" value="{!ac.Login__c}"/> </td> <td> <lightning:formattedText value="{!ac.Password__c}" /> <br /> <lightning:button iconName="utility:copy_to_clipboard" onclick="{!c.copyInputFieldValue}" label="Copy" value="{!ac.Password__c}"/> </td> <td> <lightning:formattedDateTime value="{!ac.Last_Download__c}" /> </td> <td> <lightning:formattedText value="{!ac.Location_Name__c}" /> </td> <td> <lightning:formattedText value="{!ac.Location_Address__c}" /> </td> <td> <lightning:formattedNumber value="{!ac.Bill_Cycle__c}" /> </td> <td><lightning:input type="number" aur:id="amtList" value="{!ac.Data_Bill_Benchmark__c}" name="{!rowIndex}" onchange="{!c.getAmt}"/></td> <td><button type="button" onclick="{!c.complete}" name="{!rowIndex}" class="slds-button slds-button--brand" id="{!ac.Id}">Completed</button></td> </tr> </tbody> </aura:iteration> </table> </tbody> </aura:iteration> </table> <!-- End of displaying Vendor Invoice--> </aura:iteration> </tbody> </table> </section> </lightning:card> </aura:component>
JS Controller:
getAmt : function(component, event){ var amtlist = component.find('amtList').get('v.value'); var getIndex = event.getSource().get("v.name"); var form = component.get("v.venList"); var amt = form[getIndex]; alert(amt.amtlist); component.set('v.amt', ''); },
Any help would be appreciated
- SF_Monkey
- May 29, 2019
- Like
- 0
soql query with group clause
I am trying to write a soql quey that is very similar to a summary report. I unsure but I believe that I need to group clause in the query.
This is the result that I am trying to achieve
every field on this table is from the same object. I need to group by download_cycle__c and portal_name__c.
here is what I have been written but i cant get the desired result. I have not even attempted to write the lightning component table for it.
Thanks for the help in advance
This is the result that I am trying to achieve
every field on this table is from the same object. I need to group by download_cycle__c and portal_name__c.
here is what I have been written but i cant get the desired result. I have not even attempted to write the lightning component table for it.
select count(Download_Cycle__c), Name, Last_Download__c, Portal_Name__c, count(Portal_URL__c), Password__c, Login__c, Count(Bill_Cycle__c), Location_Address__c, Location_Name__c from vendor_Invoice__c group by Name, Last_Download__c, Portal_Name__c, Password__c, Login__c, Location_Address__c, Location_Name__c
Thanks for the help in advance
- SF_Monkey
- May 15, 2019
- Like
- 0
Redirect from page layout visualforce section to visualforce tab, home page or refresh entire detail page.
Hello! I'm new in visualforce and need help.
How to resolve this bug? PageReference works but everything is going in page layout section.
- Vitalii Kaigorodtsev 7
- April 29, 2019
- Like
- 0
iterate child records with aura:component
I am tring to load the child records with aura iterate. The records are loading from soql statement and the parent records are displayed; however, the child records will not load. It is a self-lookup relation with the object.
Any help would be appreciated
<section > <div > <div class="slds-modal__content slds-p-around_medium" > <lightning:accordion allowMultipleSectionsOpen="true" > <table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer "> <div aura:id="conEditForm"> <thead> <tr class="slds-text-heading--small"> <th scope="col"><span class="slds-truncate">Name</span></th> <th scope="col"><span class="slds-truncate">Location Name</span></th> <th scope="col"><span class="slds-truncate">Login</span></th> <th scope="col"><span class="slds-truncate">Password</span></th> <th scope="col"><span class="slds-truncate" style="width:75px">Portal URL</span></th> <th scope="col"><span class="slds-truncate">Active</span></th> <th scope="col"><span class="slds-truncate">Monitored</span></th> <th scope="col"><span class="slds-truncate">Online Access</span></th> <th scope="col"><span class="slds-truncate">Last Download</span></th> <th scope="col"><span class="slds-truncate">Action</span></th> <th scope="col"><span class="slds-truncate">Record</span></th> </tr> </thead> <tbody > <aura:iteration items="{!v.data}" var="vend" indexVar="rowIndex"> <tr> <th scope="row" data-index="{!rowIndex}" onclick="{!c.toggle}" role="gridcell"> <lightning:accordionSection label="{!vend.Name}" /></th> <td><ui:outputText value="{!vend.Location_Name__c}"/></td> <td><ui:outputText value="{!vend.Login__c}"/></td> <td><ui:outputText value="{!vend.Password__c}"/></td> <td><ui:outputText value="{!vend.Portal_URL__c}"/> </td> <td><ui:outputCheckbox value="{!vend.Active_Account__c}"/></td> <td><ui:outputCheckbox value="{!vend.X180_Monitored__c}"/></td> <td><ui:outputCheckbox value="{!vend.Online_Access__c}"/></td> <td><ui:outputDate value="{!vend.Last_Download__c}"/></td> <td><button type="button" onclick="{!c.handleRowAction}" class="slds-button slds-button--neutral slds-float_center" id="{!vend.Id}">Add Child</button></td> <td><a href="{!'/one/one.app?#/sObject/'+ vend.Id + '/view'}"><ui:outputText value="Record Detail"/> </a></td> </tr> <!--Expanded section to display the child vendor invoices --> <aura:if isTrue="{!vend.expanded}"> <table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer "> <thead> <tr class="slds-text-body_small "> <th scope="col" style="width:50px"><span class="slds-truncate">Account #</span></th> <th scope="col" style="width:75px"><span class="slds-truncate">Service Type</span></th> <th scope="col" style="width:75px"><span class="slds-truncate">Aggregate Benchmark</span></th> <th scope="col" style="width:75px"><span class="slds-truncate">Location Name</span></th> </tr> </thead> <aura:iteration items="{!vend.vendor_invoices__r}" var="chil"> <tbody> <tr> <th scope="row" ><ui:outputText value="{!chil.Name}"/></th> <td ><ui:outputText value="{!chil.Service_Type__c}"/></td> <td style="width:75px"><ui:outputCurrency value="{!chil.Aggregate_Benchmark__c}"/></td> <td style="width:75px"><ui:outputText value="{!chil.Location_Name__c}"/></td> </tr> </tbody> </aura:iteration> </table> </aura:if> </aura:iteration> </tbody> </div> </table> </lightning:accordion> </div> </div> </section>
Any help would be appreciated
- SF_Monkey
- April 24, 2019
- Like
- 0
Setting page orientation when VF is exported to excel
I am trying to format excel file that is exported for VisualForce page. I am able to export the data in a table with cell width that I need. For printing, I want to set the page orientation:Landscape and width of the page to fit one page. I am unable to do that. I have two VF pages, both are for the same table but different approach. Any solution in either of the approaches will be helpful
VF 1
VF 2
VF 1
<apex:page controller="accMgrCtrl" id="pg" standardStylesheets="false" contentType="application/vnd.ms-excel#DM-Reached-Last90Days-{!TODAY()}.xls" cache="true" language="en-US"> <head> <style> @page { size:landscape; } </style> </head> <table style="border:1px solid; font-size:16px;"> <tr style="text-align:center; border:1px solid; "> <th>Name</th> <th>Next Follow-Up Date</th> <th>Next Follow-Up Action</th> <th>Primary POC</th> <th>Last DM Reached</th> </tr> <apex:repeat value="{!accList}" var="a"> <tr style="text-align:center; border:1px solid; width:auto; word-wrap: break-word;"> <td><apex:outputLink value="/{!a.id}">{!a.Name}</apex:outputLink></td> <td data-cell-type="date"><apex:outputField value="{!a.NEXT_FOLLOW_UP_DATE__c}"/></td> <td style=" word-wrap: break-word; "><apex:outputField value="{!a.Next_Action_Follow_Up__c}"/></td> <td><apex:outputField value="{!a.Primary_POC__c}"/></td> <td data-cell-type="date"> <apex:repeat value="{!a.Prospecting_Activities__r}" var="t"> <apex:outputField value="{!t.Activity_Date__c }"/> </apex:repeat> </td> </tr> </apex:repeat> </table> </apex:page>
VF 2
<apex:page controller="accMgrCtrl" contentType="application/vnd.ms-excel#DM-Reached-Last90Days-{!TODAY()}.xls" standardStylesheets="false" cache="true" language="en-US"> <apex:outputText value="{!xlsHeader}"/> <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40"> <Styles> <Style ss:ID="s1"> <Alignment/> <Borders/> <Font ss:Bold="1"/> <Interior/> <NumberFormat/> <Protection/> </Style> </Styles> <Worksheet ss:Name="Accounts"> <Table x:FullColumns="5" x:FullRows="1"> <Column ss:Width="170"/> <Column ss:Width="280"/> <Column ss:Width="330"/> <Column ss:Width="330"/> <Column ss:Width="330"/> <Row> <Cell ss:StyleID="s1"><Data ss:Type="String" >Account Name</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Next Follow-Up Date</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Next Follow-Up Action</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Primary POC</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Last DM Reached</Data></Cell> </Row> <apex:repeat value="{!accList}" var="a"> <Row> <Cell><Data ss:Type="String">{!a.name}</Data></Cell> <Cell><Data ss:Type="Date">{!a.NEXT_FOLLOW_UP_DATE__c}</Data></Cell> <Cell><Data ss:Type="String">{!a.Next_Action_Follow_Up__c}</Data></Cell> <Cell><Data ss:Type="String">{!a.Primary_POC__c}</Data></Cell> <apex:repeat value="{!a.Prospecting_Activities__r}" var="t"> <Cell><Data ss:Type="Date">{!t.Activity_Date__c}</Data></Cell> </apex:repeat> </Row> </apex:repeat> </Table> </Worksheet> </Workbook> </apex:page>
- SF_Monkey
- April 16, 2019
- Like
- 0
report api and excel
Hello everyone,
I am very new to API and writing my first API ever. I am trying to extract data from a report and put it in a formatted excel file. It is giving me an error.
Apex class
Error:
Line: 11, Column: 1
System.CalloutException: no protocol: /services/data/v45.0/analytics/reports/00OG00000046KbV
I understand that the endpoint is coming as blank. I looked at the REST API and Reports & Dashoard guide. I cannot find a way to fix this. Is it because of authorization?
Any suggestion would be appreciated!
Thanks!
I am very new to API and writing my first API ever. I am trying to extract data from a report and put it in a formatted excel file. It is giving me an error.
Apex class
public class excelReport { public excelReport(){ Http http = new http(); HttpRequest request = new HttpRequest(); string sessionId = System.UserInfo.getSessionId(); request.setEndpoint('/services/data/v45.0/analytics/reports/00OG00000046KbV'); request.setMethod('GET'); request.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionId()); request.setHeader('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); HttpResponse response = http.send(request); if(response.getStatusCode() == 200){ System.debug(response.getBody()); } } }
Error:
Line: 11, Column: 1
System.CalloutException: no protocol: /services/data/v45.0/analytics/reports/00OG00000046KbV
I understand that the endpoint is coming as blank. I looked at the REST API and Reports & Dashoard guide. I cannot find a way to fix this. Is it because of authorization?
Any suggestion would be appreciated!
Thanks!
- SF_Monkey
- March 26, 2019
- Like
- 0
Export report to an excel template
Hello everyone,
I am trying to figure out a way to export a report or a pre-formatted excel template. Basically, I would like to created a button that user clicks and it export the report or an excel file which formatted or designed that is saved on salesforce server or our local server . It is similar functionality as conga application but we are trying to build an in-house function for our custom needs. I am able to export the report and formated it later. I am new to this so any help would be appreaciated. Any starting points or general process to accomplish this ?
Thanks!
I am trying to figure out a way to export a report or a pre-formatted excel template. Basically, I would like to created a button that user clicks and it export the report or an excel file which formatted or designed that is saved on salesforce server or our local server . It is similar functionality as conga application but we are trying to build an in-house function for our custom needs. I am able to export the report and formated it later. I am new to this so any help would be appreaciated. Any starting points or general process to accomplish this ?
Thanks!
- SF_Monkey
- March 21, 2019
- Like
- 0
Checkbox not showing correct value
I have an apex method where I am comparing two list and updating a field which is a checkbox. On the table, the checbox is showing checked only the last added element to the list. I checked the log and it is working correctly according to it. Thanks!
Apex method
Lightning cmp:
Apex method
List<Prospect__c> props = [select account__c, vertical__c from Prospect__c where account__c = :accId order by name ]; List<vertical__c> verts = [select name, id from vertical__c order by name]; List<vertical__c> upper = new List<vertical__c>(); for(vertical__c m : verts){ Set<String> s = new set<string>(); s.add(m.Id); for(Prospect__c p :props){ if(s.contains(p.Vertical__c)){ m.Included__c = true; } else{ m.Included__c = false; } } upper.add(m); } update upper; return upper;
Lightning cmp:
<table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer " > <div aura:id="conEditForm" > <thead> <tr class="slds-text-heading--small"> <th scope="col"><span class="slds-truncate">Included</span></th> <th scope="col"><span class="slds-truncate">Name</span></th> <th scope="col"><span class="slds-truncate">Add</span></th> <th scope="col"><span class="slds-truncate">Remove</span></th> </tr> </thead> <tbody > <aura:iteration items="{!v.data}" var="conList" > <tr> <th scope="row"><ui:outputCheckbox value="{!conList.Included__c}" aura:id="checker"/></th> <td><a href="{!'/one/one.app?#/sObject/'+ conList.Id + '/view'}"><ui:outputText value="{!conList.Name}"/></a></td> <td><button type="button" onclick="{!c.addVert}" class="slds-button slds-button--success slds-float_center" id="{!conList.Id}">Add</button></td> <td><button type="button" onclick="{!c.delVert}" class="slds-button slds-button--destructive slds-float_center" id="{!conList.Id}">Remove</button></td> </tr> </aura:iteration> </tbody> </div> </table>
- SF_Monkey
- March 13, 2019
- Like
- 0
write test class for wrapper and else statement
Hey,
I am having issues getting the converage for the apex class (newCom). This class gives users a list of record and they can click any number of cases to attach them to the parent (Billing_Change_Form__c). I am getting 67% coverage but I am not able to cover the else statement lines.
My apex class (newCom)
My test class
The uncovered lines in the picture are where the users are click and select the cases.
Any help will be appreciated.
Thanks!
I am having issues getting the converage for the apex class (newCom). This class gives users a list of record and they can click any number of cases to attach them to the parent (Billing_Change_Form__c). I am getting 67% coverage but I am not able to cover the else statement lines.
My apex class (newCom)
// Controller for Billing Form Button on Account public with sharing class newCom { //Declare variables public account acc{get;set;} public Billing_Change_Form__c comBill {get;set;} id acID = System.currentPagereference().getParameters().get('id'); public list<conCase> caseList{get;set;} public boolean bool{get;set;} public set<id> caseIds{get;set;} ApexPages.StandardController controller; public string result{get;set;} //Contructor public newCom (ApexPages.StandardController con){ comBill = new Billing_change_form__c(); id acID = System.currentPagereference().getParameters().get('id'); comBill.RecordTypeId = '0124A000001lBu9QAE'; comBill.Account__c = acId; controller = con; caseList = new list<conCase>(); bool = false; caseIds = new Set<id>(); } //Event on clicking the checkbox public void inIt(){ List<Contingency__c> selectedCase = new list<Contingency__c>(); for(conCase conObj : caseList){ if(conObj.check != False) { system.debug('conObj.con'+ conObj.con); selectedCase.add(conObj.con); caseIds.add(conObj.con.id); bool = true; } If(conObj.check != true) {caseIds.remove(conObj.con.id); } } } //Displaying the case findings records public List<conCase> getShow(){ caseList = new list <conCase> (); for(Contingency__c coObj : [Select id, name,billing_type__c, report_description__c, discovery_amount__c, billing_begins_date__c, contingency__c, VENDOR_INVOICE__r.Account_del__r.Id from Contingency__c where (VENDOR_INVOICE__r.Account_del__r.Id = :acID) AND (contingency__c like 'IN BILLING') ORDER BY NAME]) {caseList.add(new conCase(coObj, Bool));} return caseList; } //Event on saving public PageReference comInsert(){ // newBill.RecordTypeId = '0124A000001lBu9QAE'; // Inserting the new record list<Contingency__c> noSelectedCase = [select id, name, bill_form__c from Contingency__c where id = :caseIds ]; if(noSelectedCase.size()<1){ combill.adderror('Please select a case for this form'); ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, ' Please select a case for this form' )); return null; } else{ comBill.name = 'Nada'; comBill.account__c = acID; insert comBill; result = comBill.Id; //Inserting Case Findings list<Contingency__c> updateSelectedCase = new list<Contingency__c>(); for(Contingency__c co:[select id, name, bill_form__c from Contingency__c where id = :caseIds ]) {co.bill_form__c =result ; updateSelectedCase.add(co);} update updateSelectedCase; //Redirecting Page to new record created PageReference rePage = new PageReference('/'+result); rePage.setRedirect(true); rePage.getParameters().put('id',controller.getId()); return repage;} } //Event on hitting the cancel button public PageReference noBill(){ comBill.Reason_for_Removal__c = 'Our Error'; comBill.Total_Adjustment_Amount__c = 1; comBill.Name = 'Nada'; PageReference pageRef = new PageReference('/'+acId); pageRef.setRedirect(true); return pageRef; } //Wrapper class for the selected records public class conCase{ public contingency__c con{get;set;} public boolean check{get;set;} public conCase(contingency__c c, boolean boo){ con = c; check = boo; } } }
My test class
public static testMethod void btnTestCom(){ Account accTest = new Account(); accTest.Name = 'Test Account'; insert accTest; Account accTest2 = new Account(); accTest2.Name = 'Test Account2'; insert accTest2; Account_number__c venTest = new Account_Number__c(); venTest.Name = 'Test Ven'; venTest.Account_del__c = accTest.id; insert venTest; Account_number__c venTest2 = new Account_Number__c(); venTest2.Name = 'Test Ven2'; venTest2.Account_del__c = accTest2.id; insert venTest2; Billing_Change_form__c testBill2 = new Billing_Change_Form__c(); testBill2.Name = 'Test name2'; testBill2.Reason_for_Removal__c = 'Term Completed'; testbill2.Reason_what_why__c = 'nada'; testbill2.Total_Adjustment_Amount__c = 123; insert testBill2; Billing_Change_form__c testBill = new Billing_Change_Form__c(); testBill.Name = 'Test name'; testBill.Reason_for_Removal__c = 'Term Completed'; testbill.Reason_what_why__c = 'nada'; testbill.Total_Adjustment_Amount__c = 123; insert testBill; Contingency__c caseTest = new Contingency__c(); caseTest.Name = 'test Case'; caseTest.Contingency__c = 'IN BILLING'; caseTest.vendor_invoice__c = venTest.id; insert caseTest; Contingency__c caseTest2 = new Contingency__c(); caseTest2.Name = 'test Case2'; caseTest2.Contingency__c = 'IN BILLING'; caseTest2.Bill_form__c = testBill.Id ; caseTest2.vendor_invoice__c = venTest2.id; insert caseTest2; Set<id> caseIds = new Set<id>(); caseIds.add(caseTest.id); caseIds.add(caseTest2.id); Test.startTest(); PageReference pageRef = Page.accBill; // Add your VF page Name here pageRef.getParameters().put('id', String.valueOf(testBill.Id)); Test.setCurrentPage(pageRef); ApexPages.StandardController sc = new ApexPages.StandardController(testBill); newCom testAccPlan = new newCom(sc); newCre.conCase wrap1 = new newCre.conCase(caseTest2, false); wrap1.check = true; wrap1.con = caseTest2; list<newCre.conCase> caseList = new list<newCre.conCase>(); caseList.add(wrap); caseList.add(wrap1); testAccPlan.inIt(); testAccPlan.getShow(); testAccPlan.comInsert(); testAccPlan.noBill(); test.stopTest(); }
The uncovered lines in the picture are where the users are click and select the cases.
Any help will be appreciated.
Thanks!
- SF_Monkey
- February 27, 2019
- Like
- 0
pass recordId to another lightning component using lightning:navigation
I having issues with passing the recordId from acapBtn.cmp to acapChecklist.com.
I have interface lightning:isUrlAddressable on both the component. It is navigating to the right component; however, it is not passing the recordId value to the acapChecklist.cmp.
Thanks!
acapBtn.cmp <lightning:navigation aura:id="navigationService"/> acapBtnController var recordId = component.get("v.recordId"); component.find("navigationService").navigate({ type: "standard__component", attributes: { componentName: "c__acapChecklist" }, state: { recordId: recordId } });
I have interface lightning:isUrlAddressable on both the component. It is navigating to the right component; however, it is not passing the recordId value to the acapChecklist.cmp.
Thanks!
- SF_Monkey
- February 20, 2019
- Like
- 0