-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
6Questions
-
6Replies
How do you use base lightning components in Visualforce page?
If I want to use a lightning component like a button (https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_lightning_button.htm) how would I write the JS? I know you can do custom lighting components like below
How would you write the JS for a base lightning component?
$Lightning.use("c:SampleApp", function() { $Lightning.createComponent("c:sampleComponent", {label: ""}, "lightning", function(cmp) { // Do some stuff } ); });
How would you write the JS for a base lightning component?
- Alex Yhap
- March 31, 2017
- Like
- 0
How do I get around 'Methods defined as TestMethod do not support getContent call' on controller init for Apex Test Class
Test Class
@isTest public class StandingOrdersControllerTest{ @isTest public static void test0() { PageReference pageRef = new PageReference('/apex/StandingOrders'); Test.setCurrentPage(pageRef); // 'Methods defined as TestMethod do not support getContent call' fix Blob content; if (Test.IsRunningTest()){ content = Blob.valueOf('UNIT.TEST'); }else{ content = pageRef.getContent(); } // start test Test.startTest(); // ===== error occurs here! ===== StandingOrdersController controller = new StandingOrdersController(); controller.PaymentDate = Date.today(); controller.startDate = Date.today(); controller.endDate = Date.today(); String[] tempPicklist = controller.getRecurringTypePicklist(); controller.getRecurringTypePicklist(); controller.searchTransaction(); controller.createPayments(); controller.reload(); Test.stopTest(); } @isTest public static void test1() { PageReference pageRef = new PageReference('/apex/StandingOrders'); Test.setCurrentPage(pageRef); } }Controller
public class StandingOrdersController { Public List<selectoption> RecurringOptions {get;set;} Public String RecurringType {get;set;} Public List<selectoption> PaymentTypePicklist {get;set;} Public String PaymentType {get;set;} Public Date PaymentDate {get;set;} Public List<causeview__Gift__c> giftList {get;set;} Public List<causeview__Payment__c> paymentList {get;set;} Public Boolean multiCurrencyEnabled {get;set;} Public Date startDate { get; set; } Public Date endDate { get; set; } Time startTimeGMT = Time.newInstance(0, 0, 0, 0); Time endTimeGMT = Time.newInstance(23, 0, 0, 0); Public List<TransactionObj> TransactionObjList {get{ if ( TransactionObjList == null ){ TransactionObjList = new List<TransactionObj>(); for (causeview__Gift__c g:giftList){TransactionObjList.add( new TransactionObj( g ) );} } return TransactionObjList; } private set; } Public StandingOrdersController(){ init(); } Private void init(){ RecurringType = 'Monthly'; //Set default value for picklist PaymentDate = Date.today(); RecurringOptions = initializeRecurringOptions(); //Initialize picklist PaymentTypePicklist = initializePaymentTypePicklist(); //multiCurrencyEnabled = Schema.getGlobalDescribe().containsKey('CurrencyType'); //Check if Multi-Currency is enabled searchTransaction(); } Public void searchTransaction(){ giftList = new List<causeview__Gift__c>(); System.debug('startDate: '+startDate); String f = 'ID, Name, causeview__Organization__c, causeview__Organization__r.Name, causeview__Recurring_Donation__c, causeview__Reference__c, causeview__Recurring_Donation__r.Name, causeview__Recurring_Donation__r.causeview__Type__c, causeview__Recurring_Frequency__c, causeview__Constituent__c, causeview__Constituent__r.Name, causeview__Gift_Type__c, causeview__Expected_Amount__c,causeview__Next_Payment_Date__c'; //if(multiCurrencyEnabled){f += ', CurrencyIsoCode ';} String c = 'WHERE causeview__Recurring_Donation__r.causeview__Type__c != \'ACH/PAD\' AND causeview__Recurring_Donation__r.causeview__Type__c != \'Credit Card\' AND causeview__Status__c = \'Active\''; if(startDate != null && endDate != null){ //2013-12-21T00:00:00Z String beginningOfTime = dmlDate(startDate); String endOfTime = dmlDate(endDate); c += ' AND causeview__Next_Payment_Date__c >= '+beginningOfTime+' AND causeview__Next_Payment_Date__c <= '+ endOfTime; } if(!String.isBlank(PaymentType)) { c += ' AND causeview__Recurring_Donation__r.causeview__Type__c = \''+PaymentType+'\''; } String q = 'SELECT ' + f + ' FROM causeview__Gift__c ' + c + ' LIMIT 900'; System.debug(q); giftList = Database.Query(q); TransactionObjList = null; for(causeview__Gift__c g: giftList){ system.debug(g.Name + ' : ' + g.causeview__Next_Payment_Date__c); } } Public void createPayments(){ //DEBUG System.debug('createPayments() paymentDate: ' + PaymentDate); paymentList = new List<causeview__Payment__c>(); Id standardPaymentRecordTypeId =[SELECT Id FROM RecordType WHERE Name ='UK Regular Giving' AND SobjectType ='causeview__Payment__c' Limit 1].Id; DateTime date_time; if(PaymentDate == null){ System.debug('No payment date entered.'); }else{ for(TransactionObj t:TransactionObjList) { if(t.selected){ causeview__Payment__c payment = new causeview__Payment__c(); payment.RecordTypeId = standardPaymentRecordTypeId; //payment.causeview__Date__c = t.gift.causeview__Next_Payment_Date__c; payment.causeview__Date__c = PaymentDate; payment.causeview__Amount__c = t.gift.causeview__Expected_Amount__c; payment.causeview__Status__c = 'Approved'; //payment.causeview__Payment_Type__c = '3rd-Party Payment'; if(!String.isBlank(PaymentType)) { payment.causeview__Payment_Type__c = PaymentType; } payment.causeview__Donation__c = t.gift.Id; paymentList.add(payment); } } try {insert paymentList;} catch (DmlException e) { // Process exception here System.Debug('Error inserting new payments.'); } } } Public class TransactionObj { public causeview__Gift__c gift {get; set;} public Boolean selected {get; set;} public TransactionObj( causeview__Gift__c g ){ gift = g; selected = false; } } Private List<selectoption> initializeRecurringOptions(){ RecurringOptions = new list<selectoption>(); RecurringOptions.add(new selectoption('BiWeekly','BiWeekly')); RecurringOptions.add(new selectoption('Monthly','Monthly')); return RecurringOptions; } Public PageReference reload(){ PageReference pageRef = new PageReference(ApexPages.currentPage().getUrl()); pageRef.setRedirect(true); return pageRef; } // Looks at Picklist values for a specific record type. Use 3-rd party class to retrieve list. Private List<selectoption> initializePaymentTypePicklist(){ PaymentTypePicklist = new list<selectoption>(); Id recType2Id = [Select Id from RecordType Where SobjectType = 'causeview__Payment__c' AND DeveloperName like 'UK_Regular_Giving'].Id; List<string> options = PicklistDescriber.describe('causeview__Payment__c', recType2Id, 'causeview__Payment_Type__c'); for(String pt:options){ PaymentTypePicklist.add(new selectoption(pt,pt)); } System.debug('PaymentTypePicklist: ' + PaymentTypePicklist); return PaymentTypePicklist; } //GET: Type Picklist public String[] getRecurringTypePicklist(){ String[] typePicklist = new List<String>(); Id recType2Id = [Select Id from RecordType Where SobjectType = 'causeview__Payment__c' AND DeveloperName like 'UK_Regular_Giving'].Id; List<string> options = PicklistDescriber.describe('causeview__Payment__c', recType2Id, 'causeview__Payment_Type__c'); for(String pt:options){ typePicklist.add(pt); } return typePicklist; } Public String dmlDate(Date d) { String month=String.valueOf(d.month());String day=String.valueOf(d.day()); if(integer.valueOf(d.month())<=9){month='0'+d.month();}if(integer.valueOf(d.day())<=9) {day='0'+d.day();} return d.year()+'-'+month+'-'+day; } }
- Alex Yhap
- September 06, 2016
- Like
- 0
How to iterate over custom class objects from Apex Cntrl in Apex Test?
Object class in Custom Controller
Apex Test
How do I reference PaymentWrapper from CustomController in my Apex Test class?
Does PaymentWrapperList being a transient variable hinder me for iterating over it?
public transient List< PaymentList > PaymentWrapperList; public class PaymentWrapper { public Payment__c payment { get; set; } public isSelected { get; set; } public PaymentWrapper ( payment p ){ payment = p; isSelected = false; } }
Apex Test
CustomController cc = new CustomController(); //for question for(PaymentWrapper payWrap: PaymentWrapperList) { // error occurs: Save error: Invalid type: PaymentWrapper // How do I reference PaymentWrapper in CustomController? }
How do I reference PaymentWrapper from CustomController in my Apex Test class?
Does PaymentWrapperList being a transient variable hinder me for iterating over it?
- Alex Yhap
- September 01, 2016
- Like
- 0
Update a non Sobject List from Apex class
I have a dropbox of numbers of records per page. When I select a value the assignPerPage PageReference method is called. If you look at the Visualforce page code, the apex:pageBlockTable calls the currentPage List<wrapPayment>. The desired outcome is when the assignPerPage is changed the pageBlockTable is to be updated, changing the pageSize from 10 to whatever is selected.
My question is how would I update the list or reevaluate the list to output the correct number of records per page.
My question is how would I update the list or reevaluate the list to output the correct number of records per page.
<apex:tab label="To Be Claimed" name="name1" id="tabOne"> <apex:pageMessages /> <apex:form> <apex:pageBlock id="toBeID" title="Balance: £{!sumToBeClaimed}" > <apex:pageBlockButtons location="top"> <apex:commandButton value="Process Selected" action="{!processSelected}" style="float:right;" rendered="{!IF(toBeTotalRecs==0,false,true)}"/> </apex:pageBlockButtons> <apex:pageBlock> <div style="display:inline;"> <apex:outputText value=" {!pageNumber * pageSize} - {!(pageNumber * pageSize) + pageSize} of {!toBeTotalRecs} Results"/> </div> <div style="display:inline; float:right;"> Results per page: <apex:selectList value="{!perPageSelection}" size="1"> <apex:selectOptions value="{!perPageNumbers}"></apex:selectOptions> <apex:actionSupport event="onchange" action="{!assignPerPage}" reRender="toBeID"/> </apex:selectList> </div> </apex:pageBlock> <apex:pageBlockTable value="{!currentPage}" var="claimed" id="theaddrs" styleClass="tablesorter" headerClass="header"> <apex:column > <apex:facet name="header"> <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/> </apex:facet> <apex:inputCheckbox id="inputId" value="{!claimed.selected}"/> </apex:column> <div id="{!claimed.pay.Id}"> <apex:column headerValue="Payment No"> <apex:outputLink value="{!$Site.Domain}/{!claimed.pay.Id}">{!claimed.pay.Name}</apex:outputLink> </apex:column> <apex:column value="{!claimed.pay.causeview__Constituent__c}" headerValue="Donor"/> <apex:column value="{!claimed.pay.causeview__Date__c}" headerValue="Gift Date" styleClass="header"/> <apex:column value="{!claimed.pay.Gift_Aid_Amount__c}" headerValue="Gift-Aid Amount"/> <apex:column value="{!claimed.pay.Gift_Aid_Declaration__c}" headerValue="Gif-Aid Declaration"/> </div> </apex:pageBlockTable> <apex:pageBlockButtons location="bottom" rendered="{!IF(toBeTotalRecs==0,false,true)}"> <apex:commandButton value="First" action="{!first}" rendered="{!isFirst}" rerender="toBeID"/> <apex:commandButton value="Previous" action="{!previousPage}" rendered="{!hasPrevious}" rerender="toBeID"/> <apex:commandButton value="Process Selected" action="{!processSelected}" rendered="false" rerender="toBeID"/> <apex:commandButton value="Next" action="{!nextPage}" rendered="{!hasNext}" rerender="toBeID"/> <apex:commandButton value="Last" action="{!last}" rendered="{!isLast}" rerender="toBeID"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:tab>
public Integer pageSize { get; set; } public List<wrapPayment> wrapPaymentList // Our collection of the class/wrapper objects wrapPayment { get { if ( wrapPaymentList == null ) { wrapPaymentList = new List<wrapPayment>(); //for ( causeview__Payment__c p : [SELECT Id, causeview__Constituent__c, Gift_Aid_Declaration__c, Name, causeview__Date__c, Gift_Aid_Amount__c, Gift_Aid_Claim_Status__c FROM causeview__Payment__c WHERE Gift_Aid_Claim_Status__c = 'Not claimed' AND Gift_Aid_Elegible__c = true ORDER BY causeview__Date__c DESC] ) for ( causeview__Payment__c p : [SELECT ID, Name, Gift_Aid_Claim_Status__c, House_Number__c, First_Name__c, Last_Name__c, Postal_Code__c, causeview__Constituent__c, Gift_Aid_Declaration__c, causeview__Date__c, Gift_Aid_Amount__c FROM causeview__Payment__c WHERE Gift_Aid_Claim_Status__c = 'Not claimed' AND Gift_Aid_Elegible__c = true ORDER BY causeview__Date__c DESC] ) { // As each contact is processed we create a new cContact object // and add it to the contactList wrapPaymentList.add( new wrapPayment( p ) ); } } return wrapPaymentList; } private set; } public Integer pageNumber { get; set; } public Integer numberOfPages { get; set; } private List<List<wrapPayment>> list_Pages { get { if ( list_Pages == null ) { list_Pages = new List<List<wrapPayment>>(); Integer numInPage = pageSize; List<wrapPayment> thePage; if(wrapPaymentList.size() > 0) { for ( wrapPayment pPay : wrapPaymentList ) { if ( numInPage >= pageSize ) { thePage = new List<wrapPayment>(); list_Pages.add( thePage ); numInPage = 0; } thePage.add( pPay ); numInPage++; } } } if(list_Pages.size() >0){numberOfPages = list_Pages.size() - 1;} System.Debug('list_Pages: '+list_Pages); return list_Pages; } private set; } public List<wrapPayment> currentPage { get { If(list_Pages!=null && list_Pages.size() > 0){ return list_Pages[ pageNumber ]; } else{ ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.INFO,'No record to be claimed.'); ApexPages.addMessage(myMsg); return null; } }} public PageReference assignPerPage() { pageSize = perPageSelection; return null; }
- Alex Yhap
- December 03, 2015
- Like
- 0
Merged fields with parameters in Custom Button
I have a Custom Button:
That is passed this value Conga_Solution_URL__c:
Which is results in:
As you can see the text is being encoded which I do not want. "&" is being converted to "%26" and "=" is to "%3D". I DO NOT want this action to occur...
How do I prevent the merged field from being html encoded?
Thanks
https://workflow.congamerge.com ?SessionId={!API.Session_ID} &ServerUrl={!API.Partner_Server_URL_80} {!causeview__Receipt__c.Conga_Solution_URL__c} &DS7=12 &BML=Sending+Receipt+For:+{!causeview__Receipt__c.causeview__Constituent__c}
That is passed this value Conga_Solution_URL__c:
&id=a0qq0000000gQue&EmailToId=003q000000J9l8S&CongaEmailTemplateId=a1Uq00000002E42&templateId=a1Wq00000001baX&FP0=1&LG3=1&AC0=1&SC0=1&SC1=Attachments&QMode=SendEmail
Which is results in:
https://workflow.congamerge.com/composer8/index.html?SessionId=00Dq0000000B2gd%21ARgAQEjKPP.PA2DmTqONE9W3qyo.yAhg0kqHWWIadleiv6Ww_0g7C7PSl7TON8j4as1J9K06SXbJx_rDqFamoW7lFh7XTQn1&ServerUrl=https%3A%2F%2Fcs21.salesforce.com%2Fservices%2FSoap%2Fu%2F8.0%2F00Dq0000000B2gd%26id%3Da0qq0000000gQue%26EmailToId%3D003q000000J9l8S%26CongaEmailTemplateId%3Da1Uq00000002E42%26templateId%3Da1Wq00000001baX%26FP0%3D1%26LG3%3D1%26AC0%3D1%26SC0%3D1%26SC1%3DAttachments%26QMode%3DSendEmail&DS7=12&BML=Sending+Receipt+For:+Alexander+Yhap
As you can see the text is being encoded which I do not want. "&" is being converted to "%26" and "=" is to "%3D". I DO NOT want this action to occur...
How do I prevent the merged field from being html encoded?
Thanks
- Alex Yhap
- October 27, 2015
- Like
- 0
Apex CPU Time Out & Time limit exceeded Error
When I click a button to call this Visualforce page, I get this error
Apex CPU time limit exceeded Error is in expression '{!init}' in component <apex:page> in page confirmstudents: (APXTConga4) An unexpected error has occurred. Your solution provider has been notified. (APXTConga4)Here is the code for my VF Page
<apex:page standardController="JA_Event__c" extensions="ConfirmStudentsController" action="{!init}"> </apex:page>The code for the controller:
public with sharing class ConfirmStudentsController { public ConfirmStudentsController(ApexPages.StandardController controller) { } public PageReference init() { string eventId = ApexPages.CurrentPage().getParameters().get('id'); List<Student_Registrations__c> srs = [SELECT Id, Status__c FROM Student_Registrations__c WHERE Ja_Event__c = :eventId AND Status__c = 'Confirmed']; if (srs!=null && srs.size()>0) { for(Student_Registrations__c sr : srs) sr.Status__c = 'Confirmed - Emailed'; update srs; } PageReference page = null; if (eventId != null && eventId != '') { page = new PageReference('/'+eventId); page.setRedirect(true); } return page; } @IsTest(SeeAllData=true) static void testMe() { Student_Registrations__c reg = [SELECT id, Name FROM Student_Registrations__c Limit 1]; ApexPages.StandardController std = new ApexPages.StandardController(reg); ConfirmStudentsController cnt = new ConfirmStudentsController(std); cnt.init(); } }Can someone help me to determine weather the controller's coding could be causing this error or if something else might be doing it? The debug logs didnt have much to go on but it seems that is was entering Conga's APXTConga4 package & firing off WF_RULE_INVOCATION between DML_BEGIN and DML_END log entries.
Here is a sample of the debug logs (Dont want to give the whole thing because of client information):
14:50:56.500 (36500006418)|WF_EMAIL_SENT|Template:00XC0000001ScJk|Recipients:victoriaayela@hotmail.ca |CcEmails: 14:50:56.500 (36500136190)|WF_ACTION| Field Update: 200; Task: 200; Email Alert: 200; 14:50:56.500 (36500141408)|WF_RULE_EVAL_END 14:50:56.502 (36502658216)|ENTERING_MANAGED_PKG|APXTConga4 14:50:56.521 (36521887566)|CODE_UNIT_FINISHED|Workflow:01IC0000000y2zI 14:52:40.379 (140379062327)|DML_END|[13] 14:52:40.379 (140379250658)|SYSTEM_MODE_EXIT|false 14:52:40.379 (140379374343)|CODE_UNIT_FINISHED|ConfirmStudentsController invoke(init) 14:52:40.385 (140385527191)|CUMULATIVE_LIMIT_USAGE 14:52:40.385 (140385527191)|LIMIT_USAGE_FOR_NS|(default)| Number of SOQL queries: 1 out of 100 Number of query rows: 1142 out of 50000 Number of SOSL queries: 0 out of 20 Number of DML statements: 1 out of 150 Number of DML rows: 1142 out of 10000 Maximum CPU time: 13357 out of 10000 ******* CLOSE TO LIMIT Maximum heap size: 0 out of 6000000 Number of callouts: 0 out of 100 Number of Email Invocations: 0 out of 10 Number of future calls: 0 out of 50 Number of queueable jobs added to the queue: 0 out of 50 Number of Mobile Apex push calls: 0 out of 10 14:52:40.385 (140385527191)|CUMULATIVE_LIMIT_USAGE_END 14:52:40.385 (140385601052)|CODE_UNIT_FINISHED|VF: /apex/ConfirmStudents 14:52:40.394 (140394356868)|EXECUTION_FINISHEDIf anyone can help it would be much appreciated!
- Alex Yhap
- October 23, 2015
- Like
- 0
How do I get around 'Methods defined as TestMethod do not support getContent call' on controller init for Apex Test Class
Test Class
@isTest public class StandingOrdersControllerTest{ @isTest public static void test0() { PageReference pageRef = new PageReference('/apex/StandingOrders'); Test.setCurrentPage(pageRef); // 'Methods defined as TestMethod do not support getContent call' fix Blob content; if (Test.IsRunningTest()){ content = Blob.valueOf('UNIT.TEST'); }else{ content = pageRef.getContent(); } // start test Test.startTest(); // ===== error occurs here! ===== StandingOrdersController controller = new StandingOrdersController(); controller.PaymentDate = Date.today(); controller.startDate = Date.today(); controller.endDate = Date.today(); String[] tempPicklist = controller.getRecurringTypePicklist(); controller.getRecurringTypePicklist(); controller.searchTransaction(); controller.createPayments(); controller.reload(); Test.stopTest(); } @isTest public static void test1() { PageReference pageRef = new PageReference('/apex/StandingOrders'); Test.setCurrentPage(pageRef); } }Controller
public class StandingOrdersController { Public List<selectoption> RecurringOptions {get;set;} Public String RecurringType {get;set;} Public List<selectoption> PaymentTypePicklist {get;set;} Public String PaymentType {get;set;} Public Date PaymentDate {get;set;} Public List<causeview__Gift__c> giftList {get;set;} Public List<causeview__Payment__c> paymentList {get;set;} Public Boolean multiCurrencyEnabled {get;set;} Public Date startDate { get; set; } Public Date endDate { get; set; } Time startTimeGMT = Time.newInstance(0, 0, 0, 0); Time endTimeGMT = Time.newInstance(23, 0, 0, 0); Public List<TransactionObj> TransactionObjList {get{ if ( TransactionObjList == null ){ TransactionObjList = new List<TransactionObj>(); for (causeview__Gift__c g:giftList){TransactionObjList.add( new TransactionObj( g ) );} } return TransactionObjList; } private set; } Public StandingOrdersController(){ init(); } Private void init(){ RecurringType = 'Monthly'; //Set default value for picklist PaymentDate = Date.today(); RecurringOptions = initializeRecurringOptions(); //Initialize picklist PaymentTypePicklist = initializePaymentTypePicklist(); //multiCurrencyEnabled = Schema.getGlobalDescribe().containsKey('CurrencyType'); //Check if Multi-Currency is enabled searchTransaction(); } Public void searchTransaction(){ giftList = new List<causeview__Gift__c>(); System.debug('startDate: '+startDate); String f = 'ID, Name, causeview__Organization__c, causeview__Organization__r.Name, causeview__Recurring_Donation__c, causeview__Reference__c, causeview__Recurring_Donation__r.Name, causeview__Recurring_Donation__r.causeview__Type__c, causeview__Recurring_Frequency__c, causeview__Constituent__c, causeview__Constituent__r.Name, causeview__Gift_Type__c, causeview__Expected_Amount__c,causeview__Next_Payment_Date__c'; //if(multiCurrencyEnabled){f += ', CurrencyIsoCode ';} String c = 'WHERE causeview__Recurring_Donation__r.causeview__Type__c != \'ACH/PAD\' AND causeview__Recurring_Donation__r.causeview__Type__c != \'Credit Card\' AND causeview__Status__c = \'Active\''; if(startDate != null && endDate != null){ //2013-12-21T00:00:00Z String beginningOfTime = dmlDate(startDate); String endOfTime = dmlDate(endDate); c += ' AND causeview__Next_Payment_Date__c >= '+beginningOfTime+' AND causeview__Next_Payment_Date__c <= '+ endOfTime; } if(!String.isBlank(PaymentType)) { c += ' AND causeview__Recurring_Donation__r.causeview__Type__c = \''+PaymentType+'\''; } String q = 'SELECT ' + f + ' FROM causeview__Gift__c ' + c + ' LIMIT 900'; System.debug(q); giftList = Database.Query(q); TransactionObjList = null; for(causeview__Gift__c g: giftList){ system.debug(g.Name + ' : ' + g.causeview__Next_Payment_Date__c); } } Public void createPayments(){ //DEBUG System.debug('createPayments() paymentDate: ' + PaymentDate); paymentList = new List<causeview__Payment__c>(); Id standardPaymentRecordTypeId =[SELECT Id FROM RecordType WHERE Name ='UK Regular Giving' AND SobjectType ='causeview__Payment__c' Limit 1].Id; DateTime date_time; if(PaymentDate == null){ System.debug('No payment date entered.'); }else{ for(TransactionObj t:TransactionObjList) { if(t.selected){ causeview__Payment__c payment = new causeview__Payment__c(); payment.RecordTypeId = standardPaymentRecordTypeId; //payment.causeview__Date__c = t.gift.causeview__Next_Payment_Date__c; payment.causeview__Date__c = PaymentDate; payment.causeview__Amount__c = t.gift.causeview__Expected_Amount__c; payment.causeview__Status__c = 'Approved'; //payment.causeview__Payment_Type__c = '3rd-Party Payment'; if(!String.isBlank(PaymentType)) { payment.causeview__Payment_Type__c = PaymentType; } payment.causeview__Donation__c = t.gift.Id; paymentList.add(payment); } } try {insert paymentList;} catch (DmlException e) { // Process exception here System.Debug('Error inserting new payments.'); } } } Public class TransactionObj { public causeview__Gift__c gift {get; set;} public Boolean selected {get; set;} public TransactionObj( causeview__Gift__c g ){ gift = g; selected = false; } } Private List<selectoption> initializeRecurringOptions(){ RecurringOptions = new list<selectoption>(); RecurringOptions.add(new selectoption('BiWeekly','BiWeekly')); RecurringOptions.add(new selectoption('Monthly','Monthly')); return RecurringOptions; } Public PageReference reload(){ PageReference pageRef = new PageReference(ApexPages.currentPage().getUrl()); pageRef.setRedirect(true); return pageRef; } // Looks at Picklist values for a specific record type. Use 3-rd party class to retrieve list. Private List<selectoption> initializePaymentTypePicklist(){ PaymentTypePicklist = new list<selectoption>(); Id recType2Id = [Select Id from RecordType Where SobjectType = 'causeview__Payment__c' AND DeveloperName like 'UK_Regular_Giving'].Id; List<string> options = PicklistDescriber.describe('causeview__Payment__c', recType2Id, 'causeview__Payment_Type__c'); for(String pt:options){ PaymentTypePicklist.add(new selectoption(pt,pt)); } System.debug('PaymentTypePicklist: ' + PaymentTypePicklist); return PaymentTypePicklist; } //GET: Type Picklist public String[] getRecurringTypePicklist(){ String[] typePicklist = new List<String>(); Id recType2Id = [Select Id from RecordType Where SobjectType = 'causeview__Payment__c' AND DeveloperName like 'UK_Regular_Giving'].Id; List<string> options = PicklistDescriber.describe('causeview__Payment__c', recType2Id, 'causeview__Payment_Type__c'); for(String pt:options){ typePicklist.add(pt); } return typePicklist; } Public String dmlDate(Date d) { String month=String.valueOf(d.month());String day=String.valueOf(d.day()); if(integer.valueOf(d.month())<=9){month='0'+d.month();}if(integer.valueOf(d.day())<=9) {day='0'+d.day();} return d.year()+'-'+month+'-'+day; } }
- Alex Yhap
- September 06, 2016
- Like
- 0
How to iterate over custom class objects from Apex Cntrl in Apex Test?
Object class in Custom Controller
Apex Test
How do I reference PaymentWrapper from CustomController in my Apex Test class?
Does PaymentWrapperList being a transient variable hinder me for iterating over it?
public transient List< PaymentList > PaymentWrapperList; public class PaymentWrapper { public Payment__c payment { get; set; } public isSelected { get; set; } public PaymentWrapper ( payment p ){ payment = p; isSelected = false; } }
Apex Test
CustomController cc = new CustomController(); //for question for(PaymentWrapper payWrap: PaymentWrapperList) { // error occurs: Save error: Invalid type: PaymentWrapper // How do I reference PaymentWrapper in CustomController? }
How do I reference PaymentWrapper from CustomController in my Apex Test class?
Does PaymentWrapperList being a transient variable hinder me for iterating over it?
- Alex Yhap
- September 01, 2016
- Like
- 0
Update a non Sobject List from Apex class
I have a dropbox of numbers of records per page. When I select a value the assignPerPage PageReference method is called. If you look at the Visualforce page code, the apex:pageBlockTable calls the currentPage List<wrapPayment>. The desired outcome is when the assignPerPage is changed the pageBlockTable is to be updated, changing the pageSize from 10 to whatever is selected.
My question is how would I update the list or reevaluate the list to output the correct number of records per page.
My question is how would I update the list or reevaluate the list to output the correct number of records per page.
<apex:tab label="To Be Claimed" name="name1" id="tabOne"> <apex:pageMessages /> <apex:form> <apex:pageBlock id="toBeID" title="Balance: £{!sumToBeClaimed}" > <apex:pageBlockButtons location="top"> <apex:commandButton value="Process Selected" action="{!processSelected}" style="float:right;" rendered="{!IF(toBeTotalRecs==0,false,true)}"/> </apex:pageBlockButtons> <apex:pageBlock> <div style="display:inline;"> <apex:outputText value=" {!pageNumber * pageSize} - {!(pageNumber * pageSize) + pageSize} of {!toBeTotalRecs} Results"/> </div> <div style="display:inline; float:right;"> Results per page: <apex:selectList value="{!perPageSelection}" size="1"> <apex:selectOptions value="{!perPageNumbers}"></apex:selectOptions> <apex:actionSupport event="onchange" action="{!assignPerPage}" reRender="toBeID"/> </apex:selectList> </div> </apex:pageBlock> <apex:pageBlockTable value="{!currentPage}" var="claimed" id="theaddrs" styleClass="tablesorter" headerClass="header"> <apex:column > <apex:facet name="header"> <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/> </apex:facet> <apex:inputCheckbox id="inputId" value="{!claimed.selected}"/> </apex:column> <div id="{!claimed.pay.Id}"> <apex:column headerValue="Payment No"> <apex:outputLink value="{!$Site.Domain}/{!claimed.pay.Id}">{!claimed.pay.Name}</apex:outputLink> </apex:column> <apex:column value="{!claimed.pay.causeview__Constituent__c}" headerValue="Donor"/> <apex:column value="{!claimed.pay.causeview__Date__c}" headerValue="Gift Date" styleClass="header"/> <apex:column value="{!claimed.pay.Gift_Aid_Amount__c}" headerValue="Gift-Aid Amount"/> <apex:column value="{!claimed.pay.Gift_Aid_Declaration__c}" headerValue="Gif-Aid Declaration"/> </div> </apex:pageBlockTable> <apex:pageBlockButtons location="bottom" rendered="{!IF(toBeTotalRecs==0,false,true)}"> <apex:commandButton value="First" action="{!first}" rendered="{!isFirst}" rerender="toBeID"/> <apex:commandButton value="Previous" action="{!previousPage}" rendered="{!hasPrevious}" rerender="toBeID"/> <apex:commandButton value="Process Selected" action="{!processSelected}" rendered="false" rerender="toBeID"/> <apex:commandButton value="Next" action="{!nextPage}" rendered="{!hasNext}" rerender="toBeID"/> <apex:commandButton value="Last" action="{!last}" rendered="{!isLast}" rerender="toBeID"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:tab>
public Integer pageSize { get; set; } public List<wrapPayment> wrapPaymentList // Our collection of the class/wrapper objects wrapPayment { get { if ( wrapPaymentList == null ) { wrapPaymentList = new List<wrapPayment>(); //for ( causeview__Payment__c p : [SELECT Id, causeview__Constituent__c, Gift_Aid_Declaration__c, Name, causeview__Date__c, Gift_Aid_Amount__c, Gift_Aid_Claim_Status__c FROM causeview__Payment__c WHERE Gift_Aid_Claim_Status__c = 'Not claimed' AND Gift_Aid_Elegible__c = true ORDER BY causeview__Date__c DESC] ) for ( causeview__Payment__c p : [SELECT ID, Name, Gift_Aid_Claim_Status__c, House_Number__c, First_Name__c, Last_Name__c, Postal_Code__c, causeview__Constituent__c, Gift_Aid_Declaration__c, causeview__Date__c, Gift_Aid_Amount__c FROM causeview__Payment__c WHERE Gift_Aid_Claim_Status__c = 'Not claimed' AND Gift_Aid_Elegible__c = true ORDER BY causeview__Date__c DESC] ) { // As each contact is processed we create a new cContact object // and add it to the contactList wrapPaymentList.add( new wrapPayment( p ) ); } } return wrapPaymentList; } private set; } public Integer pageNumber { get; set; } public Integer numberOfPages { get; set; } private List<List<wrapPayment>> list_Pages { get { if ( list_Pages == null ) { list_Pages = new List<List<wrapPayment>>(); Integer numInPage = pageSize; List<wrapPayment> thePage; if(wrapPaymentList.size() > 0) { for ( wrapPayment pPay : wrapPaymentList ) { if ( numInPage >= pageSize ) { thePage = new List<wrapPayment>(); list_Pages.add( thePage ); numInPage = 0; } thePage.add( pPay ); numInPage++; } } } if(list_Pages.size() >0){numberOfPages = list_Pages.size() - 1;} System.Debug('list_Pages: '+list_Pages); return list_Pages; } private set; } public List<wrapPayment> currentPage { get { If(list_Pages!=null && list_Pages.size() > 0){ return list_Pages[ pageNumber ]; } else{ ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.INFO,'No record to be claimed.'); ApexPages.addMessage(myMsg); return null; } }} public PageReference assignPerPage() { pageSize = perPageSelection; return null; }
- Alex Yhap
- December 03, 2015
- Like
- 0
Merged fields with parameters in Custom Button
I have a Custom Button:
That is passed this value Conga_Solution_URL__c:
Which is results in:
As you can see the text is being encoded which I do not want. "&" is being converted to "%26" and "=" is to "%3D". I DO NOT want this action to occur...
How do I prevent the merged field from being html encoded?
Thanks
https://workflow.congamerge.com ?SessionId={!API.Session_ID} &ServerUrl={!API.Partner_Server_URL_80} {!causeview__Receipt__c.Conga_Solution_URL__c} &DS7=12 &BML=Sending+Receipt+For:+{!causeview__Receipt__c.causeview__Constituent__c}
That is passed this value Conga_Solution_URL__c:
&id=a0qq0000000gQue&EmailToId=003q000000J9l8S&CongaEmailTemplateId=a1Uq00000002E42&templateId=a1Wq00000001baX&FP0=1&LG3=1&AC0=1&SC0=1&SC1=Attachments&QMode=SendEmail
Which is results in:
https://workflow.congamerge.com/composer8/index.html?SessionId=00Dq0000000B2gd%21ARgAQEjKPP.PA2DmTqONE9W3qyo.yAhg0kqHWWIadleiv6Ww_0g7C7PSl7TON8j4as1J9K06SXbJx_rDqFamoW7lFh7XTQn1&ServerUrl=https%3A%2F%2Fcs21.salesforce.com%2Fservices%2FSoap%2Fu%2F8.0%2F00Dq0000000B2gd%26id%3Da0qq0000000gQue%26EmailToId%3D003q000000J9l8S%26CongaEmailTemplateId%3Da1Uq00000002E42%26templateId%3Da1Wq00000001baX%26FP0%3D1%26LG3%3D1%26AC0%3D1%26SC0%3D1%26SC1%3DAttachments%26QMode%3DSendEmail&DS7=12&BML=Sending+Receipt+For:+Alexander+Yhap
As you can see the text is being encoded which I do not want. "&" is being converted to "%26" and "=" is to "%3D". I DO NOT want this action to occur...
How do I prevent the merged field from being html encoded?
Thanks
- Alex Yhap
- October 27, 2015
- Like
- 0