• TheIntegrator
  • SMARTIE
  • 704 Points
  • Member since 2010

  • Chatter
    Feed
  • 26
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 133
    Replies

How do I solve the error

REQUEST_LIMIT_EXCEEDED: TotalRequests Limit exceeded.

 

Riyaj

  • May 17, 2012
  • Like
  • 1

I am trying to create a hyperlink with several different fields populating to build it. 

For Example:
HYPERLINK(http://cp.fonality.com/call.cgi?Server_id=12345&extension=$User.Extension&username=johndoe&password=12345&number="&Phone, Call)

 

Both User Extension and Phone are fields set in Salesforce. 

The Bold text indicates the two fields we want to use for the hyperlink.  

Thanks for any advice

  • May 16, 2012
  • Like
  • 0

Hi Guys,

 

For some reason, All my the formula value are null in my APEX test method, but works all right if I manually insert some data from user interface. Is it normal?

 

But I really need some formula value for the query condition of APEX SOQL. 

 

Thanks in advance

 

 

 

 

 

 

 

 

For each Account, I need to know the ID of the Opportunity related to it that has the newest renewal date.  I was thinking that I could query Opportunity records for their ID with a GROUP BY on AccountID and a MAX(Renewal_Date__c), like this:

 

AggregateResult[] groupedResults
= [SELECT ID, AccountID, MAX(Renewal_Date__c)
FROM Opportunity
WHERE AccountID in :acctIDs AND RecordTypeID = '012A0000000qpET'
GROUP BY AccountID];

That results in a query failed error message:

 

MALFORMED_QUERY: Field must be grouped or aggregated: Id

I get why an aggregate query won't allow me to return the Opportunity ID, given that I could have several aggregate functions like AVG() and MIN() in the same query, each returning a value that corresponds to a different Opportunity ID.  But, I don't know what else to do.  

 

What is the correct way to populate the AccountID-OppID relationship map that I need in this scenario?

I have a lookup relationship between Programs__c (parent) and Requirement__c (child)

On Requirement__c  I have a picklist field called waived__c
On Programs__c  I have a picklist field called Status__c and a Text Field called Accept__c

 

I want to create a Roll up field on Programs__c called Count_Numberof_Waived_Requirements__c based on the following criteria -

 

result = SELECT Count(Id) FROM Requirements__c Where Waived__c = 'yes' AND Status__c IN ('Active', 'Enrolling')

 

and then populate the Accept__c field,

 

If (result >0){

    Accept__c = 'Yes';

}

 

 

Any suggestions or help will be appreciated.


Thanks.

Hi All,

 

I am sending an email from my apex code using Messaging.sendEmail(). Everything is working fine. But I have a onq uestion here like, what happens If I send an email to invalid email addresss(email address doen't exist). Will SF will notify me about this failure?

 

Please let me know.

 

Regd,

Naren

  • April 20, 2012
  • Like
  • 0

 im trying to execute a query based on a certain range of numbers. for example we want to query Amount > 100 and < 500.

Im trying to execute this code but im getting an error saying;

EXCEPTION_THROWN|[110]|System.QueryException: Invalid bind expression type of String for column of type Decimal

 

Double grtValue = Double.valueOf(selectedAmountGrt);
 Double lessValue = Double.valueOf(selectedAmountLess);
            Select Amount from Opportunity where Avg_Annual_Volume__c >: grtValue OR Avg_Annual_Volume__c < : lessValue';

 

 

I want to create opportunity objects on a scheduled basis. I want to have a scheduled process run every night and based on a date listed on the account, I want this process to create an opportunity for that account. Can someone help me determine what the best way to do this is?

Hello!

I have a problem with salesforce api for PHP. I can't connect.

I use XAMPP on windows 7 and free salesforce developer account..

 

 

The url:

https://127.0.0.1/sforce-php/prueba.php

 

The code:

<?php
define("USERNAME", "MyMailXXX@gmail.com");
define("PASSWORD", "My password XXX");
define("SECURITY_TOKEN", "The TOKEN XXX");
 
require_once ('soapclient/SforceEnterpriseClient.php');
 
$mySforceConnection = new SforceEnterpriseClient();
$mySforceConnection->createConnection("soapclient/enterprise.wsdl.xml");

$mySforceConnection->login(USERNAME, PASSWORD.SECURITY_TOKEN);

$query = "SELECT Id, FirstName, LastName, Phone from Contact";
$response = $mySforceConnection->query($query);
 
echo "Results of query '$query'<br/><br/>\n";
foreach ($response->records as $record) {
    echo $record->Id . ": " . $record->FirstName . " ".
        $record->LastName . " " . $record->Phone . "<br/>\n";
}
?>

 

The error message:

 

Warning: SoapClient::__doRequest() [soapclient.--dorequest]: Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in C:\xampp\htdocs\sforce-php\soapclient\SforceBaseClient.php on line 159

Fatal error: Uncaught SoapFault exception: [HTTP] SSL support is not available in this build in C:\xampp\htdocs\sforce-php\soapclient\SforceBaseClient.php:159 Stack trace: #0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'https://login.s...', '', 1, 0) #1 C:\xampp\htdocs\sforce-php\soapclient\SforceBaseClient.php(159): SoapClient->__call('login', Array) #2 C:\xampp\htdocs\sforce-php\soapclient\SforceBaseClient.php(159): SoapClient->login(Array) #3 C:\xampp\htdocs\sforce-php\prueba.php(19): SforceBaseClient->login('MymailXXX@gmail.com', 'Password+TokenXXX') #4 {main} thrown in C:\xampp\htdocs\sforce-php\soapclient\SforceBaseClient.php on line 159

 And phpinfo()

 

 

 

 

I have no idea of the error...

 

Thanks,

Jesusnoseq.

 

Context: Our sales users have a finite amount of time to work an Account before it can be pulled from their ownership and reassigned. I currently have a formula field that identifies if an Account can be reassigned by populating "YES" or "NO".

 

Desired Outcome: Run a trigger at midnight everyday that takes all Accounts where the custom forumla field Up_for_Reassignment__c says "YES" and reassigns them to the user's manager.

 

I know this involves a fairly simple trigger, but then it also requires an Apex Class that uses the Scheduler. I am not well versed in Apex Coding. Does someone have a standard Apex class built with the scheduler in it that I can insert my trigger into?

 

Thanks,

Hi,

 

I am trying to insert test data as shown below:

 

(A)

  public static List<PriceBookEntry> pricebookentries(Integer quantity) {
     
     List <PriceBook2> pb2list = new List<PriceBook2>();
     List <Product2> prodlist = new List<Product2>();
     List <PriceBookEntry> pbelist = new List<PriceBookEntry>();
     List <PriceBookEntry> stdPbelist = new List<PriceBookEntry>();
   
     Pricebook2 standardPb = [select id, name, isActive from Pricebook2 where isStandard=true];
     system.assert(standardPb!=null);
     for (Integer j = 0; j<quantity; j++){
       pb2list.add(new PriceBook2(Name = 'Test Price Book' +j, isActive = true));
     }
     insert pb2list;
     
     for (Integer j = 0; j < quantity; j++) {
       Property__c property = PropertyUtil.findByName('American Express');
       prodlist.add(new Product2(Name = 'Test Product' +j, productCode = property.Business_Unit_Code__c, isActive = true, Property__c = property.Id));
     }
     insert prodlist;
     
     for (Integer j = 0; j < quantity; j++) {
       stdPbelist.add(new PriceBookEntry(Pricebook2Id=standardPb.id, Product2Id=prodlist.get(j).id, UnitPrice=99, isActive=true, UseStandardPrice=false));
     }
     insert stdPbelist;     
     
     for (Integer j = 0; j < quantity; j++) {
       pbelist.add(new PriceBookEntry(Pricebook2Id=pb2list.get(j).id, Product2Id=prodlist.get(j).id, UnitPrice=99, isActive=true, UseStandardPrice=false));
     }
     
     insert pbelist;
     system.debug('Price Book Entry Size');
     system.debug(pbelist.size());
     
     return pbelist;
  }
    

(B)

    public static List<OpportunityLineItem> createOpportunityLineItems(Integer quantity, List<PriceBookEntry> pbes,
            List<Opportunity> opps) {
        List<OpportunityLineItem> opplineitems = new List<OpportunityLineItem>();
        
        for (Integer i = 0; i < quantity; i++) {        
            opplineitems.add(new OpportunityLineItem(Line_Item_Name__c = 'Test Opportunity Line Item' +i,
                OpportunityId  =  opps[i].Id,
                PricebookentryId =  pbes[i].Id,
                Discount = 2,
                Quantity = i,
                TotalPrice = 1000,
                Start_Date__c = Date.newInstance(2012, 01, 01),
                End_Date__C = Date.newInstance(2020, 12, 31)
                ));
                
        }
        return opplineitems;
     }
          
After caling (A) code snippet I am calling (B) to test inserting multiple records in to opp line items.

But I am getting the below issue:

 

 

"System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: PricebookEntryId (pricebook entry is in a different pricebook than the one assigned to the opportunity): [PricebookEntryId]"

 

Even though I am passing the same price book entry id to the price book entry id of opp line items (in "createOpportunityLineItems" method) which was used to insert in to price book entries :

"PricebookentryId =  pbes[i].Id"

 

I am calling (A) and (B) in a separate test  class (C) as shown below:

 

(C)

private class TestOpportunityLineItemTrigger {
   private static final Integer ACCOUNT_RECORD_COUNT = 10;
   private static final Integer OPP_RECORD_COUNT = 20;
   private static final Integer OPP_LINE_ITEM_RECORD_COUNT = 20;
   private static final Integer PRICE_BOOK_PRODUCT_COUNT = 20;
    
 
   private static testmethod void testInsertandUpdates() {
 
    Map<String, List<Account>> accounts =
                SampleDataGenerator.createAccounts(ACCOUNT_RECORD_COUNT, false,
                true);
    
    Test.startTest();
    List <PricebookEntry> pricebookentryList =
            SampleDataGenerator.pricebookentries(PRICE_BOOK_PRODUCT_COUNT);     

    List <Opportunity> oppsToInsert =
            SampleDataGenerator.createOpportunities(OPP_RECORD_COUNT,
                    accounts, false);
    for (Integer i = 0 ; i < oppsToInsert.size(); i++) {
        oppsToInsert[i].Opportunity_Name__c = 'Test Opp ' + i;
    }
    insert oppsToInsert;
    
    OpportunityLineItem[] opplineitemsToInsert =
        SampleDataGenerator.createOpportunityLineItems(OPP_LINE_ITEM_RECORD_COUNT, pricebookentryList,
                        oppsToInsert);   

}

 

 

Please help me on this issue.

 

Thanks,

JBabu.


  • April 11, 2012
  • Like
  • 0

Dear all,

 

I am hoping some can solve this puzzle. It is testing my patience. I have a lead convert trigger on convert. The trigger is supposed to create 2 custom object records but it is creating duplicates of each record so that is 4 records!!!

 

trigger LeadConvert on Lead (after update) {
     
    for(Lead lead:System.Trigger.new) {     

    if (Trigger.new.size() == 1) {
  
            if (Trigger.new[0].ConvertedAccountId != null) {
 
                Account a = [Select a.Id, a.Name, a.Description From Account a Where a.Id = :Trigger.new[0].ConvertedAccountId];
                a.Description = Trigger.new[0].Name;
                update a;
 
                    // insert a Sales Monitor Line
                    Line_del__c obj = new Line_del__c();
                    obj.Name = a.Name;
                    obj.Team_s_Dept_s_del__c = lead.Sales_Team__c;
                    obj.ME1__c = lead.Sales_ME1__c;
                    obj.ME2__c = lead.Sales_ME2__c;
                    obj.DTR3__c = lead.Sales_DTR__c; 
                    obj.CU__c = lead.Sales_CU__c;                    
                    obj.Linked_Account__c = a.Id;                    
                    insert obj;
                    
                    // insert a CR Monitor Line
                    Line_del__c obj2 = new Line_del__c();
                    obj2.Name = a.Name;
                    obj2.Team_s_Dept_s_del__c = 'a0PV0000000F8Kr';
                    obj2.ME1__c = lead.CR_ME1__c;
                    obj2.ME2__c = lead.CR_ME2__c;
                    obj2.DTR3__c = lead.CR_DTR__c; 
                    obj2.CU__c = lead.CR_CU__c;
                    obj2.Linked_Account__c = a.Id;
                    insert obj2;
                   
                 }
        
        
        }
 
    }
}

Hi All,


I have the following query which I have tested and works in SoqlXplorer.

 

SELECT Member__c, (SELECT Joined_Date__c,Joined__c FROM Opportunities__r WHERE Joined_Date__c = LAST_N_DAYS:365) FROM Contact WHERE Member__c = TRUE LIMIT 1000

 

However, my issue is I want to count the results ie like the below but this query results in MALFORMED_QUERY: Grouped query cannot use child relationships in the SELECT list

 

SELECT Count(ID), (SELECT Joined_Date__c,Joined__c FROM Opportunities__r WHERE Joined_Date__c = LAST_N_DAYS:365) FROM Contact WHERE Member__c = TRUE LIMIT 1000

 

Can anyone help.


Thanks


Kev

 

I have a very simple query that I have used in a test class to test a trigger.  This same code works in many other orgs, but for some reason returns zero results in one sandbox I am working in.

 

t.WhoId = [SELECT id FROM Contact LIMIT 1].id;

 

I see thousands of Contacts in the Sandbox and have tried even creating a new one.

 

Does anyone know why the code would return zero results and what I should do to fix it?

  • April 10, 2012
  • Like
  • 0

Inside of a trigger i'm trying to get information about the user updating the record. Is this possible? 

 

Here is what my trigger looks like:

 

trigger ContactTriggers on Contact (after insert, after update) {
	
	if(Trigger.isAfter) {
		ContactTriggers.updateAccountLastCallAttemptFields(Trigger.new);
	}
	
}

 Here is what I need:

 

trigger ContactTriggers on Contact (after insert, after update) {
	
	if(Trigger.isAfter && [RunningUser != 'a user') {
		ContactTriggers.updateAccountLastCallAttemptFields(Trigger.new);
	}
	
}

 

Is it possible to write a trigger that when an owner of a contact is change, the account owner is updated to the same owner as the contact? Also, if the account has multiple contacts associated with it, will the other contacts ownership be transferred as well? Any advice or tips would be much appreciated.

Hi All,

 

I have the requirment ,

i have one Account with Name "Test " and it has 10 Opportunities for that Account "Test" I need to allow to delete the Account "Test"  record only if the all Opportunites status have closed/own.

And i am not getting how to develop the trigger .

Can u please help me out who toi build the Logic

 

 

Regards

Anu

 

 

Hi

 

I have an object named YTD (Year To Date) and another object which is Transactions.

 

I want to create 5 custom fields on the YTD object.

 

Field 1 is Achieved - This should be the total number of Transactions done by a particular user in 2012. For example if a user has done 10 transactions in 2012, the total value of all the transactions should appear in the field. Starts from Jan 1 and will end on 31 Dec.

 

Field 2 - Value of Property Sold - This should be the total value of Purchase Price (where purchase price is a currency field on transaction object) from the transaction object. This one is also for 2012

 

Field 3 - Value of Property Leased -  This should be the total value of Annual Rent(where Annual Rent is a currency field on transaction object) from the transaction object.  This one is also for 2012

 

Field 4 - Average Sale Fee - This should be Achieved (Field 1)divided by Value of Property Sold (Field 2)

 

Field 5 - Average Rental Fee - This should be Achieved(Field 1) divided by Value of Property Leased.(Field 3)

 

All the above fields are for the current financial year i.e. Jan 2012 - Dec 2012

 

Can anyone please help me in doing this.

 

Many Thanks

 

Finney

  • April 09, 2012
  • Like
  • 0

I have a trigger on Quote to prorate line items.   But I need to access attributes from the Product for the QuoteLineItem which is defined as Field Product2 and Type Lookup(Product).  How can I get the ProductCode, Description and Name of the QuoteLineItem's Product?

Hello

 

I have created a lookup field named Assets in contact and i want to select more then one asset. Can anyone suggest me how can i do it.

 

Thanks!

When trying to merge accounts in our org, we get the following error:

 

Query is either selecting too many fields or the filter conditions are too complicated.
Error is in expression '{!selectMerge}' in component <apex:page> in page dupe_eliminator:searchmerge

An unexpected error has occurred. Your solution provider has been notified. (dupe_eliminator)

 

Could it be because we have a lot of custom fields on account? (over 300) Is there a workaround?

 

Thanks

I was looking for a number to word code for apex today and to my disappointment, the only think I could find was a paid app on appexchange http://appexchange.salesforce.com/listingDetail?listingId=a0N300000059Vz6EAE

 

which I though was ridiculous, so I created my own, its not perfect, but it works and I wanted to share it in the community.

 

public static string wtn(Decimal i, String curr)
      {
          String text='';
          String bigD='', smallD='';
          Decimal Bn=0, Gn=0, Kn=0, Hn=0, Dn=0, tDn=0, dec=0;
          Integer n=0;
          
          String[] ones = new String[]{'', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 
            'Seven', 'Eight', 'Nine', 'Ten', 'Eleven', 'Twelve', 'Thirteen', 
            'Fourteen', 'Fifteen', 'Sixteen', 'Seventeen', 'Eightteen', 
            'Nineteen'};
          String[] tens = new String[]{'', 'Twenty', 'Thirty', 'Fourty', 'Fifty', 'Sixty', 
            'Seventy', 'Eigthy', 'Ninety'};

           //More currencies can be added
          if(curr == 'USD'){ bigD='Dollar'; smallD='Cent';}
          else if(curr == 'IRD'){ bigD='Rupiah'; smallD='Sen';}
          
          if((i==null)||(i < 0 )|| (i > 99999999999.99))
              return 'Out of range';
          
          Bn = math.floor(i/100000000); //Billion
          i=i-Bn*100000000;
          Gn = math.floor(i/1000000); //Million
          i=i-Gn*1000000;
          Kn = math.floor(i/1000); //Thousand
          i=i-Kn*1000;
          Dn = math.floor(i/100); //Hundred
          if(Dn ==0)
              tDn =math.floor(i/10);
          else
              tDn =math.floor(math.mod(integer.valueof(i),100)/10);
          dec = math.mod(math.mod(integer.valueof(i*100),100), 100);
          i=i-Dn*100;
     
          n=math.mod(integer.valueof(i),10); //Ones
                   
          if(Bn !=0)
              text = text + wtn(Bn, curr)+ ' Billion ';
          if(Gn !=0)
              text = text + wtn(Gn, curr)+ ' Million ';
          if(Kn !=0)
              text = text + wtn(Kn, curr)+ ' Thousand ';
          if(Dn !=0)
              text = text + wtn(Dn, curr)+ ' Hundred ';                         
          

          if(tDn !=0 || n !=0){
              if(text!='')
                  text = text + ' and ';
              if(tDn <2){
                  text = text + ones[integer.valueof(tDn)*10 + n];
              }else{
                  text = text + tens[integer.valueof(tDn)-1];
                  if(n!=0)
                      text = text + ' - ' + ones[n];
              }
          }
          if(dec !=0){
              text = text +' '+bigD+' and '+ wtn(dec, curr) + ' '+smallD;
          }
          if(text == '')
              text = 'zero';
          
          return text;
      }

 

so if I call  wtn(250.99,'USD');

I get "Two Hundred and Fifty Dollar and Ninety - Nine Cent"

 

As I said, the code is not perfect, if there are no decimal numbers, the code doesn't print "Dollar", some space issues etc.

 

The function can be added in a global class and called in before triggers to fill a text field with the amount in words, or it can be called in a visualforce print and so on.

Hope it helps someone.


Was just wondering if there is a way to query "API Requests, Last 24 Hours" which is displayed in Company Information under Company Profile in setup? I would like to query this information and make an informative decision with the web service calls. I appreciate your feedback

Was just wondering if there is a way to query "API Requests, Last 24 Hours" which is displayed in Company Information under Company Profile in setup? I would like to query this information and make an informative decision with the web service calls.

 

I appreciate your feedback

How do I solve the error

REQUEST_LIMIT_EXCEEDED: TotalRequests Limit exceeded.

 

Riyaj

  • May 17, 2012
  • Like
  • 1

I was working in my sandbox environment trying to figure out the API calls - i had saved my refresh token during my testing but it was lost sometime later during my testing. 

 

Now when I try to hit the API i am receiving: 

 

"expired access/refresh token" 

 

How do I get around this now?  I do not have a refresh token so i cannot make a request to refresh my token, and i'm not sure how to expire / delete / revoke it via the UI so that I can proceed with my testing.  

 

 

my cUrl call is as follows: 

 

 

curl
    --form client_id=3MVG92.u...2KycWe
    --form client_secret=668...930
    --form grant_type=password
    --form username=mike....com
    --form password=*#()@*#$@
  https://test.salesforce.com/services/oauth2/token --proxy 127.0.0.1:3128 --insecure

 

 

 

 

I am trying to create a hyperlink with several different fields populating to build it. 

For Example:
HYPERLINK(http://cp.fonality.com/call.cgi?Server_id=12345&extension=$User.Extension&username=johndoe&password=12345&number="&Phone, Call)

 

Both User Extension and Phone are fields set in Salesforce. 

The Bold text indicates the two fields we want to use for the hyperlink.  

Thanks for any advice

  • May 16, 2012
  • Like
  • 0

Hi Guys,

 

For some reason, All my the formula value are null in my APEX test method, but works all right if I manually insert some data from user interface. Is it normal?

 

But I really need some formula value for the query condition of APEX SOQL. 

 

Thanks in advance

 

 

 

 

 

 

 

 

I have a situation where a child object (Claim__c) technically has multiple Master-Detail relationships.  Since SF does not support this, I needed to create an Apex Trigger to create a roll up summary for one of the 'parent' custom objects (Coverage__c) that is a lookup field (Claim_Coverage__c on object Claim__c).  Here is what I am trying to do:

 

On the Coverage__c custom object populate a field called Coverage_Total_Indemnity_PD__c with a calculation of the Indemnity_PD__c field on Claim__c.

 

This is new to me with Apex but I have made an attempt at the trigger (below) but keep getting the following error:

Error: Compile Error: Variable does not exist: ListCoverages at line 27 column 20

(I note in the code below the line with the error)


From what I understand, this variable does exist earlier in the trigger so I am not sure how to resolve.  Any help is resolving this error is greatly appreciated!  

 

 

trigger CoverageIndemnityPDTrigger On Claim__c(after insert, after update){
set<Id> setCoverageid=new set<Id>();
Map<string,Decimal> CoveragewithTotalIndemnityPD=new Map<string,Decimal>();
for(Claim__c acs:Trigger.New){
if(acs.Claim_Coverage__c!=null && acs.Indemnity_PD__c!=null){
setCoverageid.add(setCoverageid);
}
}

if(setCoverageid.size()>0){
List<Coverage__c> ListCoverages = [Select Id, Coverage_Total_Indemnity_PD__c from Coverage__c where Coverage__c =:setCoverageid];
List<Claim__c> ListCoverageClaims = [Select Id, Indemnity_PD__c from Claim__c where Coverage__c =:setCoverageid and Indemnity_PD__c!=null];
for(Id CoverageId:setCoverageid){
Decimal totCovIndPD=0;
for(Claim__c acs: ListCoverageClaims){
if(CoverageId=acs.Coverage_c){
totCovIndPD=totCovIndPD + acs.Indemnity_PD__c ;
}
}
CoveragewithTotalIndemnityPD.put(CoverageId,totCovIndPD);

}
}

List<Coverage__c> UpdateCoverage=new List<Coverage__c>();

 

****BELOW IS THE LINE THAT CONTAINS THE ERROR -- THE ERROR IS 'LISTCOVERAGES')*****

for(Coverage__c MC:ListCoverages){

 

MC.Coverage_Total_Indemnity_PD__c=CoveragewithTotalIndemnityPD.get(MC.id);
UpdateCoverage.add(MC);
}

if(UpdateCoverage.size()>0){
update UpdateCoverage;
}

}

  • April 30, 2012
  • Like
  • 0

Hello,

 

I'm looking into the possiblity of creating Circular Many-To-Many relationships with Salesforce. For instance if I would like to incorporate Users following other Users in some sort of Feed. Not like chatter, it's actually for use in Database.com.

 

Thanks in advance.

  • April 30, 2012
  • Like
  • 0

Hi

 

Can anyone provide solution. How to take a value of recent Dtae of child record   from all child records associated with it.

For each Account, I need to know the ID of the Opportunity related to it that has the newest renewal date.  I was thinking that I could query Opportunity records for their ID with a GROUP BY on AccountID and a MAX(Renewal_Date__c), like this:

 

AggregateResult[] groupedResults
= [SELECT ID, AccountID, MAX(Renewal_Date__c)
FROM Opportunity
WHERE AccountID in :acctIDs AND RecordTypeID = '012A0000000qpET'
GROUP BY AccountID];

That results in a query failed error message:

 

MALFORMED_QUERY: Field must be grouped or aggregated: Id

I get why an aggregate query won't allow me to return the Opportunity ID, given that I could have several aggregate functions like AVG() and MIN() in the same query, each returning a value that corresponds to a different Opportunity ID.  But, I don't know what else to do.  

 

What is the correct way to populate the AccountID-OppID relationship map that I need in this scenario?

Hi all,

 

I have a problem getting the value from an AgreggateResult returned by an SOQL. Here is the code from the SOQL:

 

        total = [SELECT SUM(Total_Net__c)tmp
                 FROM Selected_Product__c
                 WHERE Service_Reservation__c =:servOrder
                 GROUP BY Service_Reservation__c];
              system.debug('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'+total);    

 That system.debug gives me this: 

 

16:17:01:123 USER_DEBUG [24]|DEBUG|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%(AggregateResult:{tmp=40.0})

 Which is the value I want to show. In a different method I try to return 'result' as integer this way:

 

    public integer result {get; set;}

...


 public integer getResult(){
    
       integer result;
       for(AggregateResult ar:total){
       
           result = (integer)ar.get('tmp');
       system.debug('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'+result);
       }
                                     
       return result;
    }

NOTE: When I debug this it never gets to the system.debug, but salesforce allows me to save this code (hence, no syntax errors).

 

And in the VF page I call for result this way:

 

<apex:outputText value="{!result}"/>

 

And no result at all (empty).

 

Do you have any idea of why this is happening?. Any solution?

 

Many thanks,

 

MGA.

Is there any way to remove the Edit|Del option in the related list?

I have pieced together  a trigger in order to clone a Closed Won opportunity. The one part I do not understand is that I want the new Opportunity's name to be in the format of "Opp Name - Renewal - Year" with Year being the year after the current one. So if I Closed Won an Opportunity today (2012), then the cloned opportunity name would become "Opportunity Name - Renewal - 2013".

 

I have the Name - Renewal part but what do I need to add after it to get the dynamic year?

 

 newOpp.Name=o.Name + ' - Renewal';

 


Thank you!

I have a lookup relationship between Programs__c (parent) and Requirement__c (child)

On Requirement__c  I have a picklist field called waived__c
On Programs__c  I have a picklist field called Status__c and a Text Field called Accept__c

 

I want to create a Roll up field on Programs__c called Count_Numberof_Waived_Requirements__c based on the following criteria -

 

result = SELECT Count(Id) FROM Requirements__c Where Waived__c = 'yes' AND Status__c IN ('Active', 'Enrolling')

 

and then populate the Accept__c field,

 

If (result >0){

    Accept__c = 'Yes';

}

 

 

Any suggestions or help will be appreciated.


Thanks.

Hi there,

 

I need to enhance this trigger so it can check duplicates based on the City name, Street Name and Account name.

 

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

trigger AccountCreateTrigger on Account (before insert) {
for (Account acc: Trigger.new)
     {Account [] accs = [SELECT Name FROM Account WHERE Name = :acc.Name LIMIT 1];
      if (accs.size() > 0 ) //if account already exists, block and show the information on the page
         {acc.addError('Account  \'' + accs[0].Name +  '\' already exists. Please use existing account or contact your Salesforce Administrator for assistance.'); }
     }
}

////////////////////////////////////////////

 

 

The above trigger only displays error message if the Account Name entered by User is the same to the Account Name already existed.

 

For example:-

 

a) Accucom - Baulkham Hills - is already existing.

 

b) Accucom Ltd. - Baulkham Hills - this value should not be allowed to save, but the user is able to save this record if the Account Name is slightly different.

 

How can i make sure that if the Site_City Name field is same and the Street Name, along with the Account Name then do not allow to save records.

 

Any recommendations???

 

Could some please tell me, how do i query OpportunityTeamMember.

 

Lets say i've an Opportunity with some team members. Hoe do i retrieve them.

 

This is what i've tried:

Request => SELECT UserId FROM OpportunityTeamMember WHERE OpportunityId ='{some_id}' 

 

Response => 

.

<faultcode>sf:INVALID_TYPE</faultcode>
<faultstring>INVALID_TYPE:
SELECT UserId FROM OpportunityTeamMember WHERE OpportunityId
^
ERROR at Row:1:Column:20
sObject type 'OpportunityTeamMember' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.</faultstring>
<detail>
<sf:InvalidSObjectFault xsi:type="sf:InvalidSObjectFault">
<sf:exceptionCode>INVALID_TYPE</sf:exceptionCode>
<sf:exceptionMessage>SELECT UserId FROM OpportunityTeamMember WHERE OpportunityId
^
ERROR at Row:1:Column:20
sObject type 'OpportunityTeamMember' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.</sf:exceptionMessage>
<sf:row>1</sf:row>
<sf:column>20</sf:column>
</sf:InvalidSObjectFault>
</detail>

 

Regards

Farukh D M

.