• Kumar Vikash 9
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies

I am planning to add a button on the Opportunity Page to email the payments and its status as an attachment to the Primary Contact. I want to include -
1. The payment scheduled date, and
2. Corresponding payment amount (even though it would be the same) 
3. Payment Status (even though it would be unpaid)

I like the solution from SDocs, but want to create it in-house.
For generating the pdf, I am using the below code - 
 

<apex:page controller="vik_ThisOpportunityController" renderAs="pdf">
    <apex:form >
    	<h1 style="font-family: sans-serif; font-size:20px;">
            Payments Details for the Opportunities
        </h1>
        <p style="font-family: sans-serif; font-size:16px;">
            For your recurring donation, please find below the details on payments
        </p>
        <table style="width: 100%;">
            <tr style="font-size: 0.8em; font-family: sans-serif; ">
                    <th style="padding: 8px;
                               text-align: left; border-bottom: 1px solid #ddd;">Scheduled Date</th>
                    <th style="padding: 8px;
                               text-align: left; border-bottom: 1px solid #ddd;">Payment Amount</th>
                    <th style="padding: 8px;
                               text-align: left; border-bottom: 1px solid #ddd;">Payment Status</th>
            </tr>
            <apex:repeat value="{! payments }" var="pay">
            	<tr style="font-family: sans-serif; font-size: 0.8em;">
                	<td style="padding: 8px; text-align: left; 
                               border-bottom: 1px solid #ddd;">{!pay.npe01__Scheduled_Date__c}</td>
                    <td style="padding: 8px; text-align: left; 
                               border-bottom: 1px solid #ddd;">{!pay.npe01__Payment_Amount__c}</td>
                    <td style="padding: 8px; text-align: left; 
                               border-bottom: 1px solid #ddd;">{!pay.Payment_Status__c}</td>
                </tr>
            </apex:repeat>
        </table>
    </apex:form>
</apex:page>
Corresponding controller - 
public class vik_ThisOpportunityController {
    
    private final List<npe01__opppayment__c> payments;
    
    public vik_ThisOpportunityController() {
        List<npe01__opppayment__c> payments = [SELECT npe01__Scheduled_Date__c, npe01__Payment_Amount__c, Payment_Status__c 
                                               FROM npe01__opppayment__c 
                                               WHERE npe01__Opportunity__r.Id='006f400000CdtQjAAJ'];
    }
    
    public List<npe01__opppayment__c> getPayments() {
        return payments;
    }
}
Please find below the result from the Query Editor, which I want to replicate in the pdf - 
Query result with separate payments and their status

Right, now I am just trying to develop a table for a static Opportunity ID and later plan to make it dynamic, so that I can add a button in the Opportunity page, which picks up the Opportunity ID, and emails the related payments. My problem is that, even with the static content, I am not getting any output-
Current output pdf with no rows
I have a feeling that I might even not need a custom controller for this as Payment is intrinsic to the npsp Salesforce, but still it would be really appreciated if you could help me troubleshoot this.

Thanks!
Challenge Requirements:
Create a flow:
Name: New Lead
Type: Screen Flow
In the flow, add a screen with these required screen fields.
Last Name
Company Name
In the flow, create a lead record.
Use the screen fields to set the lead’s Last Name and Company.
Store the lead’s ID in a Text variable called leadId.
In the flow, add another screen with a Lightning component screen field.
Name the field Upload_File
Choose the forceContent:fileUpload Lightning component.
Use the leadId variable to set the component's Related Record ID attribute.
Activate the New Lead flow.
Create a new Lightning page:
Type: Home page
Label: Process Automation Home
In Process Automation Home, add a Flow component that references the New Lead flow.
Activate the page and set it as the default Home page.

I did all of this and yet it says it cannot detect force content?User-added image
User-added image
My client implemented  SF and they get donations through enquiry form.Donors pay amount by Creditcard. My client looking for Payment gateway apps which should process credit card information and integrate to SF and should generate reciepts for the amount donated.  Any Suggestions.
What Payment Gateway Apps from App Exchange you Recommend.   Look Forward for your valuable suggestions

I think the Spring '11 release changed the behavior of some batch apex classes depending on how queries are used. I am now getting the following exception in a batch apex class that I haven't touched in over a year:

 

System.QueryException: Aggregate query has too many rows for direct assignment, use FOR loop

 

From what I can tell this started happening after the Spring 11 update.

 

Here is the simple code to reproduce the issue:

 

global class BatchJob implements Database.Batchable<sObject>{

	public string query = 'select Id, Name, (Select Id from Contacts) from Account';

	global Database.QueryLocator start(Database.BatchableContext bc){
		return Database.getQueryLocator(query); 
	}
	
	global void execute(Database.BatchableContext bc, List<sObject> objects){
	 	List<Account> accts = new List<Account>();
	 	for(sObject s : objects){
	 		Account a = (Account)s;
	 		system.debug('Throw error...');
	 		system.debug(a.Contacts); //This will throw a 'silent' System.QueryException
	 	}
	}
	 
	global void finish(Database.BatchableContext bc){
		system.debug('All done.');	 
	}
}

And here is the test class:

 

@isTest
private class BatchBugTEST {

    static testMethod void myUnitTest() {
        Account acct = new Account(Name = 'test');
        insert acct;
        
	//create some contacts
	List<Contact> cons = new List<Contact>();
		
	Integer count = 0;
	for(Integer i = 0; i < 200; i++){
		cons.add(new Contact(AccountId = acct.Id, LastName = 'test' + i));
	}
	insert cons;
	system.debug(cons.size());
		
	//Setup batch job       
        BatchJob job = new BatchJob();
	job.query += ' where Id = \'' + acct.Id + '\'';
		 
	Test.startTest();
	Database.executeBatch(job);
	Test.stopTest();
    }
}

What is most concerning about this is the System.QueryException is "silent". What I mean by this is that the code keeps running as if no exception occurred. Usually when a system exception occurs everything comes to a screeching halt and errors are displayed as test failures on the results page. In the case the code continues and the only way to see the error is to locate it in the debug logs.

 

The only reason I caught this error was good unit tests with assertions. If I didn't have these I would have had no idea this class stopped working correctly. I will be submitting a support ticket but if anyone from salesforce can run the code above on a Winter 11 instance I would be interested what the results are.

 

-Jason

 

 

 

 

  • February 14, 2011
  • Like
  • 0