• Carissa Crittenden
  • NEWBIE
  • 15 Points
  • Member since 2015
  • Salesforce Admin & Marketing Coordinator
  • BirdDogHR


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 9
    Replies
I'm trying to build a printable PDF for records of a Custom Object, as well as the related child objects (also custom objects). I found this thread http://boards.developerforce.com/t5/Visualforce-Development/Rendering-mutiple-records-with-related-lists/m-p/272751/highlight/false#M34985 but I'm not sure how to implement it. I'm still in the early stages of building, so everything is super basic right now.

Here's my VF
<apex:page standardController="Demo_Request__c" renderAs="pdf">
    <body>
        <div id="account-info">
            <apex:panelGrid columns="2" width="100%">
                Account:<apex:outputText value="{!Demo_Request__c.Account__r.Name}"/>
                Owner: <apex:outputField value="{!Demo_Request__c.Owner.Name}"/>
            </apex:panelGrid>
        </div>
        

    </body>
</apex:page>
I'm great with clicks - not so much with the code. I added this apex class in as an extension to my VF (along with modified code from the thread I linked above) and I got errors. Here's the class as I modified it - throwing an error on line 5 - guessing I plugged the wrong thing in to that last get.
public with sharing class DemoRequest {
    public Demo_Request__c oList{ get; set; }
    public DemoRequest ()
    {
        String demoRequestQueryId = (String[])ApexPages.currentPage().getParameters().get('demorequest');
        String soqlQuery = 'select id, Name from Demo_Request__c';
        oList= Database.query(soqlQuery);

    }
    
}

Not sure where I went wrong or what other information to provide. TIA.
I am super new to Apex and consequently struggling through. I created an Apex class with the intent that I will trigger it with Process Builder. I built a test class for it and I'm getting the error "Method does not exist or incorrect signature: void updateCustomer(Id) from the type CustomerAccountingUpdate.

Here's my Apex Class:
public class CustomerAccountingUpdate {
        
    public static string updateCustomer(Account aAccount) {
    	aAccount.c2g__CODAAccountsReceivableControl__c = System.Label.GeneralLedgerAcctsRec;
        aAccount.c2g__CODASalesTaxStatus__c = 'Taxable';
        aAccount.c2g__CODATaxCode1__c = 'AvaTax';
        aAccount.c2g__CODADaysOffset1__c = 0;
        aAccount.c2g__CODADescription1__c = 'Due Upon Receipt';
       
        update aAccount;
        
        return 'success';
    }
}


And my test Class:
@isTest(SeeAllData=true)
public class CustomerAccountingUpdateTest {
	static private Account setUpTestEnvironment() {          
         Account a =  new Account(
                               Name = 'Test Accounting Test'
                               ,Type = 'Prospect'            				   
                           );
         insert a;
        return a;
    }
    static testMethod void AccountingUpdateTest() {
         Account a = setUpTestEnvironment();
   
         Test.startTest();
         
         CustomerAccountingUpdate.updateCustomer(a.id);
         
         Test.stopTest();
    }
}


Thanks so much - this is the first time I've written a class & test totally from scratch rather than modifying something that was already there so I have no idea where I'm going wrong.
 
I have an Apex Class written by my in-house non-Salesforce developer. I tried to modify it and am now getting an internal server error. Here's the part of the code that works (there's a lot more, I'm just not showing it here).
private static string processSale(Quote aQuote) {
               
       if (aQuote.Opportunity.Account.Member_ID__c == null || aQuote.Opportunity.Account.Member_ID__c == '') {
          aQuote.Opportunity.Account.Member_ID__c = generateMemberID(aQuote.Opportunity.Account.Name);
       }      
        
       //New clients - Build the Contract
        if (aQuote.Signed_MSSA__c == false && aQuote.Opportunity.Type == 'New Business') {
            Contract aContract = new Contract (
                AccountId = aQuote.Opportunity.Account.id
                ,ContractTerm = aQuote.Initial_Contract_Term_Length__c.intValue()
                ,StartDate = aQuote.Initial_Contract_Start_Date__c
                ,Status = 'Draft'
                ,Number_of_Quotes__c = 1
            	);
            insert aContract; 
            
            aContract.Status = 'Activated';
            update aContract;

            aQuote.ContractId = aContract.Id;
            
            aQuote.Opportunity.ContractId = aContract.Id;
            
        }
}
The part that isn't working is this:
//Existing clients - Append to the Contract
        if (aQuote.ContractId != null && aQuote.Opportunity.Type != 'New Business') {
          /*  List<Contract> updateContract = New List<Contract>();
            For(Contract con : [Select id, Number_of_Quotes__c , Addendums__c FROM Contract WHERE Id = :aQuote.ContractId]){
                con.Addendums__c = aQuote.Addendum__c;
                con.Number_of_Quotes__c = con.Number_of_Quotes__c + 1;
            }
				
			update updateContract;   
            For (Contract con : [Select id, Number_of_Quotes__c , Addendums__c FROM Contract WHERE Id = :aQuote.ContractId] ){
                con.Number_Of_Quotes__c = con.Number_of_Quotes__c + 1;
                con.Addendums__c = aQuote.Addendum__c;
            }
            
            update con;*/
            
            //This throws an internal server error
                Contract updateContract = [SELECT id, Number_of_Quotes__c , Addendums__c FROM Contract Where Id = :aQuote.ContractId LIMIT 1];
            
                updateContract.Number_of_Quotes__c = updateContract.Number_of_Quotes__c + 1;
                updateContract.Addendums__c = aQuote.Addendum__c;
            update updateContract;
            
                
       }

Essentially, this is a combination of everything I've tried and it didn't work. the first List/For bit threw an internatl server error. The second For bit didn't actually do anything (but didn't throw an error - it didn't update the contract though). The bit under the "//This throws an internal server error" obviously didn't work either. 

I'm a coding novice - pretty solid admin, but code is still new to me so I'm self-teaching as I go. Any and all help is appreciated.

As a note, the ContractId for aQuote is being grabbed at the bottom of the Apex Class in a getQuoteSOFor call (call? statement? method?)
 
Hi,

I'm brand new to apex. I'm trying to update an already existing apex class with some code that will, based on field values, create a new record. I then want to update the Quote and Opportunity to tie back to that newly created record and I'm getting the error for "Variable does not exist" for everything I'm trying.

Here's a snippet of the code I'm using. It does more than just this, but the errors are being thrown at the aQuote.ContractId & aQuote.Opportunity.ContractId
 
private static string processSale(Quote aQuote) {
               
               
       
        if (aQuote.IsPaid__c && (aQuote.Opportunity.Account.Has_a_signed_MSSA__c == 'No' || aQuote.Opportunity.Account.Has_a_signed_MSSA__c == null	) && aQuote.Opportunity.Account.Type != 'Current Customer') {
            Contract aContract = new Contract (
                AccountId = aQuote.Opportunity.Account.id
                ,ContractTerm = aQuote.Initial_Contract_Term_Length__c.intValue()
                ,StartDate = aQuote.Initial_Contract_Start_Date__c
            	);
            
            insert aContract;  
            
                      
            aQuote.ContractId = aContract.Id;
            aQuote.Opportunity.ContractId = aContract.Id;
                        
            update aQuote;
            update aQuote.Opportunity;
        }
}

What do I need to do to ensure the Opp & Quote records get tied back to the Contract?

Thanks!
So I have a visualforce page that renders as a PDF. I have some text I want to only show up under certain circumstances. Here's that code:
<apex:outputPanel layout="none" rendered="{!IsFastTrackOnlySale}">After the Initial Contract Term, this agreement automatically renews for additional one-year terms (annual fees become due 30 days prior to the renewal date) unless either party gives written notice of non-renewal at least 60 days before the end of the term.</apex:outputPanel>

And the Apex Class I have that should be getting this information is....
public boolean getIsFastTrackOnlySale() {
        List<QuoteLineItem> ftlis = [select id 
                                from QuoteLineItem 
                                where quoteid = :theQuote.id 
                                    and PriceBookEntry.Product2.Family = 'Managed Services'
                              ];
        List<QuoteLineItem> alllis = [select id 
                                from QuoteLineItem 
                                where quoteid = :theQuote.id 
                              ];
                              
        return (ftlis.size() == alllis.size());
    }

I can't figure out why the sentence continues to render in the PDF when IsFastTrackOnlySale is rendering true.

Any insight or help is appreciated!

Thanks! 
I am super new to Apex and consequently struggling through. I created an Apex class with the intent that I will trigger it with Process Builder. I built a test class for it and I'm getting the error "Method does not exist or incorrect signature: void updateCustomer(Id) from the type CustomerAccountingUpdate.

Here's my Apex Class:
public class CustomerAccountingUpdate {
        
    public static string updateCustomer(Account aAccount) {
    	aAccount.c2g__CODAAccountsReceivableControl__c = System.Label.GeneralLedgerAcctsRec;
        aAccount.c2g__CODASalesTaxStatus__c = 'Taxable';
        aAccount.c2g__CODATaxCode1__c = 'AvaTax';
        aAccount.c2g__CODADaysOffset1__c = 0;
        aAccount.c2g__CODADescription1__c = 'Due Upon Receipt';
       
        update aAccount;
        
        return 'success';
    }
}


And my test Class:
@isTest(SeeAllData=true)
public class CustomerAccountingUpdateTest {
	static private Account setUpTestEnvironment() {          
         Account a =  new Account(
                               Name = 'Test Accounting Test'
                               ,Type = 'Prospect'            				   
                           );
         insert a;
        return a;
    }
    static testMethod void AccountingUpdateTest() {
         Account a = setUpTestEnvironment();
   
         Test.startTest();
         
         CustomerAccountingUpdate.updateCustomer(a.id);
         
         Test.stopTest();
    }
}


Thanks so much - this is the first time I've written a class & test totally from scratch rather than modifying something that was already there so I have no idea where I'm going wrong.
 
I do not have any coding experience but hoping someone can help me write the code to Print to PDF from a Custom Object.  We have a Custom Object called "Executive Summary" and I would like to print to PDF when a button is clicked.  I was able to create the button but I can not get it to do anything.  Help Please?  Below is a Screen Shot of my custom object.
User-added image
I have an Apex Class written by my in-house non-Salesforce developer. I tried to modify it and am now getting an internal server error. Here's the part of the code that works (there's a lot more, I'm just not showing it here).
private static string processSale(Quote aQuote) {
               
       if (aQuote.Opportunity.Account.Member_ID__c == null || aQuote.Opportunity.Account.Member_ID__c == '') {
          aQuote.Opportunity.Account.Member_ID__c = generateMemberID(aQuote.Opportunity.Account.Name);
       }      
        
       //New clients - Build the Contract
        if (aQuote.Signed_MSSA__c == false && aQuote.Opportunity.Type == 'New Business') {
            Contract aContract = new Contract (
                AccountId = aQuote.Opportunity.Account.id
                ,ContractTerm = aQuote.Initial_Contract_Term_Length__c.intValue()
                ,StartDate = aQuote.Initial_Contract_Start_Date__c
                ,Status = 'Draft'
                ,Number_of_Quotes__c = 1
            	);
            insert aContract; 
            
            aContract.Status = 'Activated';
            update aContract;

            aQuote.ContractId = aContract.Id;
            
            aQuote.Opportunity.ContractId = aContract.Id;
            
        }
}
The part that isn't working is this:
//Existing clients - Append to the Contract
        if (aQuote.ContractId != null && aQuote.Opportunity.Type != 'New Business') {
          /*  List<Contract> updateContract = New List<Contract>();
            For(Contract con : [Select id, Number_of_Quotes__c , Addendums__c FROM Contract WHERE Id = :aQuote.ContractId]){
                con.Addendums__c = aQuote.Addendum__c;
                con.Number_of_Quotes__c = con.Number_of_Quotes__c + 1;
            }
				
			update updateContract;   
            For (Contract con : [Select id, Number_of_Quotes__c , Addendums__c FROM Contract WHERE Id = :aQuote.ContractId] ){
                con.Number_Of_Quotes__c = con.Number_of_Quotes__c + 1;
                con.Addendums__c = aQuote.Addendum__c;
            }
            
            update con;*/
            
            //This throws an internal server error
                Contract updateContract = [SELECT id, Number_of_Quotes__c , Addendums__c FROM Contract Where Id = :aQuote.ContractId LIMIT 1];
            
                updateContract.Number_of_Quotes__c = updateContract.Number_of_Quotes__c + 1;
                updateContract.Addendums__c = aQuote.Addendum__c;
            update updateContract;
            
                
       }

Essentially, this is a combination of everything I've tried and it didn't work. the first List/For bit threw an internatl server error. The second For bit didn't actually do anything (but didn't throw an error - it didn't update the contract though). The bit under the "//This throws an internal server error" obviously didn't work either. 

I'm a coding novice - pretty solid admin, but code is still new to me so I'm self-teaching as I go. Any and all help is appreciated.

As a note, the ContractId for aQuote is being grabbed at the bottom of the Apex Class in a getQuoteSOFor call (call? statement? method?)
 
Hi,

I'm brand new to apex. I'm trying to update an already existing apex class with some code that will, based on field values, create a new record. I then want to update the Quote and Opportunity to tie back to that newly created record and I'm getting the error for "Variable does not exist" for everything I'm trying.

Here's a snippet of the code I'm using. It does more than just this, but the errors are being thrown at the aQuote.ContractId & aQuote.Opportunity.ContractId
 
private static string processSale(Quote aQuote) {
               
               
       
        if (aQuote.IsPaid__c && (aQuote.Opportunity.Account.Has_a_signed_MSSA__c == 'No' || aQuote.Opportunity.Account.Has_a_signed_MSSA__c == null	) && aQuote.Opportunity.Account.Type != 'Current Customer') {
            Contract aContract = new Contract (
                AccountId = aQuote.Opportunity.Account.id
                ,ContractTerm = aQuote.Initial_Contract_Term_Length__c.intValue()
                ,StartDate = aQuote.Initial_Contract_Start_Date__c
            	);
            
            insert aContract;  
            
                      
            aQuote.ContractId = aContract.Id;
            aQuote.Opportunity.ContractId = aContract.Id;
                        
            update aQuote;
            update aQuote.Opportunity;
        }
}

What do I need to do to ensure the Opp & Quote records get tied back to the Contract?

Thanks!
So I have a visualforce page that renders as a PDF. I have some text I want to only show up under certain circumstances. Here's that code:
<apex:outputPanel layout="none" rendered="{!IsFastTrackOnlySale}">After the Initial Contract Term, this agreement automatically renews for additional one-year terms (annual fees become due 30 days prior to the renewal date) unless either party gives written notice of non-renewal at least 60 days before the end of the term.</apex:outputPanel>

And the Apex Class I have that should be getting this information is....
public boolean getIsFastTrackOnlySale() {
        List<QuoteLineItem> ftlis = [select id 
                                from QuoteLineItem 
                                where quoteid = :theQuote.id 
                                    and PriceBookEntry.Product2.Family = 'Managed Services'
                              ];
        List<QuoteLineItem> alllis = [select id 
                                from QuoteLineItem 
                                where quoteid = :theQuote.id 
                              ];
                              
        return (ftlis.size() == alllis.size());
    }

I can't figure out why the sentence continues to render in the PDF when IsFastTrackOnlySale is rendering true.

Any insight or help is appreciated!

Thanks!