• RobJCowell
  • NEWBIE
  • 0 Points
  • Member since 2011

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

So we're using the apex-lang libraries (http://code.google.com/p/apex-lang/) which has its own set of test classes.

 

When we do a "run all tests", it passes fine, but when we try to deploy some of our own classes, the deployment fails in those apex-lang test classes with :-

 

Failure Message: "System.Exception: null", Failure Stack Trace: "External entry point"

 

Anyone got any ideas on how we get out of this one?

So another SOQLbuilder question - why is SUM(Total_USD_Gross__c) the only field in the output SQL ?

 

companyquery = new SoqlBuilder()
                .selectx('Event_to_Deal__r.Client_Company__r.ID')
                .selectx('Event_to_Deal__r.Client_Company__r.Name')
                .selectsumx('Total_USD_Net__c')
                .selectsumx('Total_USD_Gross__c')
                .fromx('Event_Costs__c')
                .wherex(new SetCondition('Event_to_Deal__r.Client_Company__r.ID').inx(comps))
                .groupByx('Event_to_Deal__r.Client_Company__r.ID')
                .toSOQL();

  which yields the following SOQL

 

SELECT SUM(Total_USD_Gross__c) FROM Event_Costs__c WHERE Event_to_Deal__r.Client_Company__r.ID IN ('a0220000004aPRAAA2','a0220000006Fb7CAAS','a0220000004ZaYxAAK') GROUP BY Event_to_Deal__r.Client_Company__r.ID

 

Where are ID, Name and the other SUM ?  The following manual SOQL works, and is the kind of thing I'm expecting SOQLbuilder to construct

 

SELECT Event_to_Deal__r.Client_Company__r.ID,Event_to_Deal__r.Client_Company__r.Name,SUM(Total_USD_Gross__c) Gross, SUM(total_USD_Net__c) Net FROM Event_Costs__c WHERE Event_to_Deal__r.Client_Company__r.ID IN ('a0220000004aPRAAA2','a0220000006Fb7CAAS','a0220000004ZaYxAAK') GROUP BY Event_to_Deal__r.Client_Company__r.ID,Event_to_Deal__r.Client_Company__r.Name

 

So I'm using Richard Vanhook's SOQLBuilder from the apex-lang code library and I'm trying to migrate my string-concatenation SQL code to the new approach.  The problem I'm hitting is when I need to add WHERE clauses dynamically depending on values set elsewhere.

 

Consider the following :-

 

companyquery = 'SELECT Event_to_Deal__r.Client_Company__r.ID FROM Event_Costs__c WHERE ';
            if (market != 'All')
                companyquery +='Event_to_Deal__r.LNOperation__c = \'' + market + '\'';
            
            if (industry != 'All')
            {
                if (companyquery.substring(companyquery.length()-6) != 'WHERE ')
                    companyquery += ' AND ';
                companyquery += 'Event_to_Deal__r.Client_Company__r.Industry__c = \'' + industry + '\'';
            }   
            
            if (sector != 'All')
            {
                if (companyquery.substring(companyquery.length()-6) != 'WHERE ')
                    companyquery += ' AND ';
                companyquery += 'Event_to_Deal__r.Client_Company__r.Sectors__c = \'' + sector + '\'';    
            }
            
            if (companyquery.substring(companyquery.length()-6) != 'WHERE ')
                    companyquery += ' AND ';
            companyquery += 'Event_to_Deal__r.Status__c = \'Current\'';

 Standard trickery for building these in strings, but how can you do the same kind of thing in SOQLBuilder?  It doesn't seem to support being interrupted while you do an if statement, nor does it seem to be concatenatable.

 

Thanks

 

Rob

So another SOQLbuilder question - why is SUM(Total_USD_Gross__c) the only field in the output SQL ?

 

companyquery = new SoqlBuilder()
                .selectx('Event_to_Deal__r.Client_Company__r.ID')
                .selectx('Event_to_Deal__r.Client_Company__r.Name')
                .selectsumx('Total_USD_Net__c')
                .selectsumx('Total_USD_Gross__c')
                .fromx('Event_Costs__c')
                .wherex(new SetCondition('Event_to_Deal__r.Client_Company__r.ID').inx(comps))
                .groupByx('Event_to_Deal__r.Client_Company__r.ID')
                .toSOQL();

  which yields the following SOQL

 

SELECT SUM(Total_USD_Gross__c) FROM Event_Costs__c WHERE Event_to_Deal__r.Client_Company__r.ID IN ('a0220000004aPRAAA2','a0220000006Fb7CAAS','a0220000004ZaYxAAK') GROUP BY Event_to_Deal__r.Client_Company__r.ID

 

Where are ID, Name and the other SUM ?  The following manual SOQL works, and is the kind of thing I'm expecting SOQLbuilder to construct

 

SELECT Event_to_Deal__r.Client_Company__r.ID,Event_to_Deal__r.Client_Company__r.Name,SUM(Total_USD_Gross__c) Gross, SUM(total_USD_Net__c) Net FROM Event_Costs__c WHERE Event_to_Deal__r.Client_Company__r.ID IN ('a0220000004aPRAAA2','a0220000006Fb7CAAS','a0220000004ZaYxAAK') GROUP BY Event_to_Deal__r.Client_Company__r.ID,Event_to_Deal__r.Client_Company__r.Name

 

So I'm using Richard Vanhook's SOQLBuilder from the apex-lang code library and I'm trying to migrate my string-concatenation SQL code to the new approach.  The problem I'm hitting is when I need to add WHERE clauses dynamically depending on values set elsewhere.

 

Consider the following :-

 

companyquery = 'SELECT Event_to_Deal__r.Client_Company__r.ID FROM Event_Costs__c WHERE ';
            if (market != 'All')
                companyquery +='Event_to_Deal__r.LNOperation__c = \'' + market + '\'';
            
            if (industry != 'All')
            {
                if (companyquery.substring(companyquery.length()-6) != 'WHERE ')
                    companyquery += ' AND ';
                companyquery += 'Event_to_Deal__r.Client_Company__r.Industry__c = \'' + industry + '\'';
            }   
            
            if (sector != 'All')
            {
                if (companyquery.substring(companyquery.length()-6) != 'WHERE ')
                    companyquery += ' AND ';
                companyquery += 'Event_to_Deal__r.Client_Company__r.Sectors__c = \'' + sector + '\'';    
            }
            
            if (companyquery.substring(companyquery.length()-6) != 'WHERE ')
                    companyquery += ' AND ';
            companyquery += 'Event_to_Deal__r.Status__c = \'Current\'';

 Standard trickery for building these in strings, but how can you do the same kind of thing in SOQLBuilder?  It doesn't seem to support being interrupted while you do an if statement, nor does it seem to be concatenatable.

 

Thanks

 

Rob