function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
impalacrazy69impalacrazy69 

SOQL query to grab accont fields

So attached is my code in my controller that is looking to pull the account data using the lookup filed called Partner__c. For some reason nothing is being pulled over. Does anyone see what i am missing this seems so simple but is causing such a headache...

         public PageReference getresellerInfo (){ 
    	
  		Account a = [SELECT Id, Name, Phone, Account.BillingStreet, Account.BillingCity,   Account.BillingState, Account.BillingPostalCode, Account.BillingCountry
                     FROM Account
                     WHERE Id = :this.request.Partner__c];

   	 if(this.request.Partner__c != null){
            this.request.Company_Phone__c = a.Phone;
            this.request.Company_Address__c = a.BillingStreet;
            this.request.Company_City__c = a.BillingCity;
            this.request.Company_Postal__c = a.BillingPostalCode;
            this.request.Company_Country__c = a.BillingCountry;           
            this.request.Company_State__c = a.BillingState;
    	}
              
            system.debug('in the getresellerInfo method monkey balls 2');
    		  
            return null;
            
    		   	
    } 

 

Saikishore Reddy AengareddySaikishore Reddy Aengareddy

use system.debug to print the value of this.request.partner__c and see if its coming as null... from where exactly are you getting the value request.partner__c???

Puja_mfsiPuja_mfsi

Hi,

Please explain from where r u getting the value of "this.request.Partner__c". As you have mention in post it seems request.partner__c contains NULL.

impalacrazy69impalacrazy69

Partner__c is the lookup field on my VF page that pulls from account. The controller is long so here is the top of it where i declare this.request equal to the Marketing Request object which has the file Partner__c as a lookup to accounts.

public class vfMarketingRequestController {
        // Request record we are creating
        public Marketing_Request__c request {get; set;}
        // Attachment
    public Attachment attachment {get; set;}
        
        // Product Section check box options
        // Needs to map to multi-picklist upon save
        String[] products = new String[]{};
        
        // Materials Requirements checkboxes
        // Needs to map to multi-picklist upon save
        String[] materials = new String[]{};
        
        // Used to display different steps in the process
    public Boolean isValid {public get; private set;}
        
        
        // CONTSTRUCTOR
    public vfMarketingRequestController(ApexPages.StandardController controller) {
        this.isValid = false;
        
        this.request = (Marketing_Request__c) controller.getSubject();

 

 

impalacrazy69impalacrazy69

yes the system debug is return back a null

Puja_mfsiPuja_mfsi

Hi,

You need to make a query to get the value of Partner__c on Marketing_Request__c.

from this line

this.request = (Marketing_Request__c) controller.getSubject();

u can't get the value of Marketing_Request__c object fields. first you make a query and get the value of partner__c.

 

Marketing_Request__c marketingReq = [select Id,Partner__c from Marketing_Request__c where id =: request.Id];

 

and then use in the account query :

Account a = [SELECT Id, Name, Phone, Account.BillingStreet, Account.BillingCity, Account.BillingState, Account.BillingPostalCode, Account.BillingCountry
FROM Account
WHERE Id = :marketingReq.Partner__c];

 

Please let me know if you have any problem on same.If this post is helpful please give KUDOS by click on star at left.

 

impalacrazy69impalacrazy69

So i added in the query and the code saved with no issues. However now when i click on my link to grab the data and pull to the screen nothing happens.  Attached is the updated code as well as the VF page code that has the copy link calling the class.

 

public PageReference getresellerInfo (){ 
         	
         	 // Get Reseller ID
        Marketing_Request__c marketingReq = [SELECT Id,Partner__c from Marketing_Request__c where id =: request.Id];
    	
  		Account a = [SELECT Id, Name, Phone, Account.BillingStreet, Account.BillingCity, Account.BillingState, Account.BillingPostalCode, Account.BillingCountry
                     FROM Account
                     WHERE Id = :marketingReq.Partner__c];
                     
  	    if(this.request.Partner__c != null){
            
            this.request.Company_Address__c = a.BillingStreet;
            this.request.Company_City__c = a.BillingCity;
            this.request.Company_Postal__c = a.BillingPostalCode;
            this.request.Company_Country__c = a.BillingCountry;           
            this.request.Company_State__c = a.BillingState;
            this.request.Company_Phone__c = a.Phone;
    	}
              system.debug(request.Partner__c);
    		  
            return null;
            
    		   	
    }   

 

VF page:

  <apex:outputpanel id="Requestordetailspanel">
	<apex:actionregion >
    <apex:pageBlockSection columns="1" id="resellertovendor">
        <apex:pageBlockSectionItem rendered="{!isInternal}">
        
            <apex:outputLabel >Copy to Vendor</apex:outputLabel>
          <apex:outputpanel >
            <b><apex:commandlink value="Copy" action="{!getresellerInfo}" rerender="vendordetailspanel"/></b>
           <apex:outputtext > Note: Reseller is the same as Vendor </apex:outputtext>
          </apex:outputpanel>
      </apex:pageBlockSectionItem>
        
    </apex:pageBlockSection>     
 
  </apex:actionregion>
    </apex:outputpanel> 

 Thanks for your help by the way :D