• barfsurfer
  • NEWBIE
  • 30 Points
  • Member since 2010

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

My team just received funding for a project to develop a custom front-end solution in salesforce.com.  We need someone with great experience in apex, database, and visuaforce to come in and create a solution for us.  This is probably a 2 month gig working for BeckmanCoulter, one of Orange County's largest companies and a leader in healthcare.  We would prefer someone local, but would consider remote if you've really got the skills!  Please reply to this thread if you're interested and we can start the conversation.

We have a quoting application that lives on the opportunity.  Users enter the app by clicking a new quote button on the quotes related list section.  I wanted to validate that a particular pricebook was being used prior to allowing the user to enter the quoting system.

 

I've done javascript validation buttons in the past, and it works well -- something like this for example:

 

if (({!Opportunity.Ship_To_Count__c == 0}) || ({!Opportunity.No_of_Bill_To_Sites__c == 0 })) { alert('Your Opportunity is missing a Bill-To or Ship-To Site. At least 1 Bill-To and 1 Ship-To site are required to create a Quote. Please select the appropriate Bill-To and Ship-To sites using the "Select Bill-To and Ship-To button on the Opportunity page.');} else { location.replace('/apex/BM_NewQuote?oppId={!Opportunity.Id}&actId={!Opportunity.AccountId}');}

 But if I try to stick Opportunity.Pricebook2Id in there, it errors and says the field doesn't exist.  I know it does, I can see it in the schema.  Why is this field "hidden" from some parts of the app?  Any other ideas?  I'm stuck!

 

I have a successfully working controller and VF page.  Part of the reason for this controller was to bypass sharing rules.  BUT,  I need one of the methods in this controller to run with sharing.  So, I essentially created a standalone "with sharing" class with 1 method that does the querying, and returns the list of accounts back to the main controller.

 

Here's the original controller method that works:

 

    public List<aAccount> getSTAccounts(){
        if (STaccountList == null){
                STaccountList = new List<aAccount>();
                //This  query returns all site accounts in the hierarchy of the opp account where Ship To = True
                for(Account a : [Select id, Site_Number__c, Name, BillingStreet, BillingState, BillingCity From Account where 
                              parentid =:ApexPages.currentPage().getparameters().get('parentid') and Active_Ship_To__c = true Order by BillingCity, BillingStreet]){
                              STaccountList.add(new aAccount(a)); 
                              }                                                      
        }
        return STaccountList;
    }

All I really need to do is execute the above query with sharing rules in place.  So here's my standalone class:

 

public with sharing class multiShipToUtility {
/*
This little utility class is part of the whole BMI multi-bill to ship-to picker app.
For selecting the ship to sites, we need that list to be driven by sharing rules.  
In the bill to selection, we want the user to be able to see ALL bill to sites, regarless of territory
But for ship tos, we want that to be driven by territory assignment.  
To accomplish both, I had to break out the ship to selection into a separate class with sharing.
*/     
     
     public  static List<Account> getSTAccounts(string stParentId){
                string stID = stparentId;
                List<Account> STaccountList = new List<Account>();
                //This  query returns all site accounts in the hierarchy of the opp account where Ship To = True
                for(Account a : [Select id, Site_Number__c, Name, BillingStreet, BillingState, BillingCity From Account where 
                              parentid =: stParentId and Active_Ship_To__c = true Order by BillingCity, BillingStreet]){
                              STaccountList.add(a); 
                              }                                                      

        return STaccountList; 
     } 
}

 

So, back to the  main controller, I re-wrote the method like this:

 

    public List<aAccount> getSTAccounts(){

        if (STaccountList == null){
        string stParentID = ApexPages.currentPage().getparameters().get('parentid');
        List<Account> shipTos = new List<Account>();
        shipTos = multiShipToUtility.getSTAccounts(stParentID);
        for (Account a: shipTos){
        	STaccountList.add(new aAccount(a));
        }

       
        return STaccountList;    
        }

 

 

This won't compile with the message Non-void method might not return a value or might have statement after a return statement".

I researched this error a bit, and then added a basic else clause to the if-block above to return an empty list.  This compiles, but then blows up when I run the page:  "Attempt to de-reference a null object"

 

I also tried removing the static keyword from the method, but that doesn't compile eiter. 

 

So I'm totally stuck now.  Can anyone offer any suggestions? 

 

 

 

 

 

My team just received funding for a project to develop a custom front-end solution in salesforce.com.  We need someone with great experience in apex, database, and visuaforce to come in and create a solution for us.  This is probably a 2 month gig working for BeckmanCoulter, one of Orange County's largest companies and a leader in healthcare.  We would prefer someone local, but would consider remote if you've really got the skills!  Please reply to this thread if you're interested and we can start the conversation.

We have a quoting application that lives on the opportunity.  Users enter the app by clicking a new quote button on the quotes related list section.  I wanted to validate that a particular pricebook was being used prior to allowing the user to enter the quoting system.

 

I've done javascript validation buttons in the past, and it works well -- something like this for example:

 

if (({!Opportunity.Ship_To_Count__c == 0}) || ({!Opportunity.No_of_Bill_To_Sites__c == 0 })) { alert('Your Opportunity is missing a Bill-To or Ship-To Site. At least 1 Bill-To and 1 Ship-To site are required to create a Quote. Please select the appropriate Bill-To and Ship-To sites using the "Select Bill-To and Ship-To button on the Opportunity page.');} else { location.replace('/apex/BM_NewQuote?oppId={!Opportunity.Id}&actId={!Opportunity.AccountId}');}

 But if I try to stick Opportunity.Pricebook2Id in there, it errors and says the field doesn't exist.  I know it does, I can see it in the schema.  Why is this field "hidden" from some parts of the app?  Any other ideas?  I'm stuck!

 

I have a successfully working controller and VF page.  Part of the reason for this controller was to bypass sharing rules.  BUT,  I need one of the methods in this controller to run with sharing.  So, I essentially created a standalone "with sharing" class with 1 method that does the querying, and returns the list of accounts back to the main controller.

 

Here's the original controller method that works:

 

    public List<aAccount> getSTAccounts(){
        if (STaccountList == null){
                STaccountList = new List<aAccount>();
                //This  query returns all site accounts in the hierarchy of the opp account where Ship To = True
                for(Account a : [Select id, Site_Number__c, Name, BillingStreet, BillingState, BillingCity From Account where 
                              parentid =:ApexPages.currentPage().getparameters().get('parentid') and Active_Ship_To__c = true Order by BillingCity, BillingStreet]){
                              STaccountList.add(new aAccount(a)); 
                              }                                                      
        }
        return STaccountList;
    }

All I really need to do is execute the above query with sharing rules in place.  So here's my standalone class:

 

public with sharing class multiShipToUtility {
/*
This little utility class is part of the whole BMI multi-bill to ship-to picker app.
For selecting the ship to sites, we need that list to be driven by sharing rules.  
In the bill to selection, we want the user to be able to see ALL bill to sites, regarless of territory
But for ship tos, we want that to be driven by territory assignment.  
To accomplish both, I had to break out the ship to selection into a separate class with sharing.
*/     
     
     public  static List<Account> getSTAccounts(string stParentId){
                string stID = stparentId;
                List<Account> STaccountList = new List<Account>();
                //This  query returns all site accounts in the hierarchy of the opp account where Ship To = True
                for(Account a : [Select id, Site_Number__c, Name, BillingStreet, BillingState, BillingCity From Account where 
                              parentid =: stParentId and Active_Ship_To__c = true Order by BillingCity, BillingStreet]){
                              STaccountList.add(a); 
                              }                                                      

        return STaccountList; 
     } 
}

 

So, back to the  main controller, I re-wrote the method like this:

 

    public List<aAccount> getSTAccounts(){

        if (STaccountList == null){
        string stParentID = ApexPages.currentPage().getparameters().get('parentid');
        List<Account> shipTos = new List<Account>();
        shipTos = multiShipToUtility.getSTAccounts(stParentID);
        for (Account a: shipTos){
        	STaccountList.add(new aAccount(a));
        }

       
        return STaccountList;    
        }

 

 

This won't compile with the message Non-void method might not return a value or might have statement after a return statement".

I researched this error a bit, and then added a basic else clause to the if-block above to return an empty list.  This compiles, but then blows up when I run the page:  "Attempt to de-reference a null object"

 

I also tried removing the static keyword from the method, but that doesn't compile eiter. 

 

So I'm totally stuck now.  Can anyone offer any suggestions?