• Machhi
  • NEWBIE
  • 0 Points
  • Member since 2009

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

Hi,

 

Has anybody come across below issue with Salesforce?

 

The batch Apex job processed 5 batches with 0 failures.

 

Error I am getting is:

Update failed. First exception on row 0 with id 001Q0000005U7c4IAC; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, trigAccount: execution of BeforeUpdate caused by: System.Exception: Too many SOQL queries: 201 Class.AssetUtility.GetAssetsForAccount: line 109, column 30 Class.AccountUtility.ResetFlagOnUpdate: line 236, column 30 Trigger.Account: line 29, column 17: []

I have traced following things:  

Error record number on which I am getting error: 600

 

Total records to be processed :678

 

Query being used by Batch Apex:select Id, Number_of_Cases__c, Number_of_Contracts__c from Contact

 

This application has simple task to updat account records. Below is the code in the Execute call:

/* Execute : This function performs Batch Update process */ global void execute(Database.BatchableContext BC, List<sObject> scope) { /* Loop through each records list as per the Query paramater. Perform the updates */ List<Account> accountsToUpdate = new List<Account>{}; try { for(sObject s : scope) { Account a = (Account)s; if(blnIsIncludeNumberOfCases) a.Number_of_Cases__c = [select count() from Case where Account.id = :a.id]; if(blnIsIncludeNumberOfContracts) a.Number_of_Contracts__c = [select count() from Contract where Account.id = :a.id]; AccountsToUpdate.Add(a); iCountForAccount++; } //Update all accounts in batch update AccountsToUpdate; } catch(Exception e) { iErrorRecordNumber = iCountForAccount; strMessage = 'Error with Batch Apex : ' + e.getMessage() + '<br />Error record number: ' + iErrorRecordNumber; } } //End of Execute

 

This seems like Salesforce governance limit, bt I need to know how to overcome this.

  

Please help.

 

Regards,

Chandrakant M

  • October 30, 2009
  • Like
  • 0

I have person accounts enabled for my organization.

 

I am trying to update a contact record. When I execute update query and if the contact record is my person account, it throws me below error:

 

INVALID CROSS REFERENCE KEY

Cannot select a person account.

 

I can understand that the contact record is actually referring to person account .. but then why should I able to select it using - select id from contact where id = 'personaccountid'?  

 

 

If anybody knows the resolutions, please do let me know.

 

 

Regards,

Chandrakant M

  • October 14, 2009
  • Like
  • 0
I am trying to write a test method for mass update utility.

It simply calls a future method. Please see below code snippet:

.....
.....
//Run the method for Contact update utility
Test.startTest();
CustomUtilityHelper.ContactUpdateUtility(DateTime.now().year()+ '',1,true,false);
Test.stopTest();

//Assert the count for cases against the above contact record
Decimal numberOfcasesForContact = [select Id, Number_of_Cases__c from contact where id=:PrimaryContact.id].Number_of_Cases__c;
System.debug('Test case count against contact :' + numberOfcasesForContact);
System.assert(numberOfcasesForContact==1, 'Test case count against contact failed.');
.....
.....

This CustomUtilityHelper.ContactUpdateUtility() method loops through all contact records in the system for current year.
My organization have near about 3000 contact records. So I choose to use Future call.

Can any one please advice me whether this will work from the past experience? This test method validates positive test, then negative test and hence the above call is made twice or thrice or more. So this results in number of SOQL queries increased resulting in failure of test method.

Does anybody know best practices to write test method for such type of requirement?

Thanks in advance.
  • October 14, 2009
  • Like
  • 0

Hi All,

 

I am facing problems with mass updates of records module design. I had to change my appl design in lot of way because of below scenario:

 

Scenario:

I need to update mass contact records based on filter criteria. Fields to be updated are the count of number of cases and activities against the respective contact records.

 

How it works:

I have a Visualforce page from where I call a method from the custom controller class.

 

This method queries on contact records based on filter criteria. Divide them into the quantitative batches. Collects a set of Ids for one batch and pass it to future method (asynchronous).

 

Issue:

1. Even though I am using future method, I get “Too many SOQL queries: 101” error.

I learnt that a future method allows me to work on 10,000 SOQL queries or DML statements (http://wiki.developerforce.com/index.php/Governors_in_Apex_Code).

 

Due to this, I can work only on a batch of 99 records.

Shouldn’t it be 10,000 SOQL queries which I can process in future method called through Visualforce controller?

 

2. If I activate trigger, this batch size is still decreased as execution of trigger also adds SOQL queries.

 

I don’t understand why execution of trigger adds SOQL queries to my future method limit. Even it adds to it, why it throws error after 100 SOQL queries? Also, I am also looking for an option by which I can stop trigger from being executed if I am updating records from my Visualforce controller. Having a flag field and check its value inside trigger work around is sarcastic.    

 

Please help. Salesforce looks quite intelligent to answer mass records updates requirement using future annotation but as I have experienced up to now, I can process only 700-800 records successfully not more than that which is simply not acceptable.

 

Regards,

Chandrakant M

machhi_c_m@yahoo.com

Message Edited by Machhi on 10-09-2009 12:27 AM
Message Edited by Machhi on 10-09-2009 12:28 AM
  • October 09, 2009
  • Like
  • 0
Hi, I have Person Account enabled in my organization. Also, I have two Record Types created for Person accounts.   While writing unit function, I have a need to create personal account using APEX code of one of the record types. Has anybody written APEX code for the same?  I have tried below code that I collected from the community threads, but gives me an error at last line:  Error message: System.DmlException: Update failed. First exception on row 0 with id 001Q0000004sztRIAQ; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: [].  Code: 
Contact newContact = new Contact( firstname= 'Bob', lastname='Test', email = 'bob@test.com');insert newContact;Account newAccount = new Account (name = 'Bob Test');insert newAccount;newContact.accountId = newAccount.Id;update newContact;//get the person account record typeRecordType personaccountrecordtype = [select Id, Name, SobjectType,         IsPersonType from RecordType where SobjectType='Account'         and IsPersonType=True and DeveloperName=’MyPersonalAccountRecordType’];Account[] convertAccounts = [Select id, RecordtypeId from Account where Id = :newAccount.Id ];convertAccounts[0].RecordTypeId = personaccountrecordtype.Id;convertAccounts[0].LastName = newContact.lastname;System.debug(Database.update(convertAccounts));
 Regards,Chandrakant M

Hi,

 

Has anybody come across below issue with Salesforce?

 

The batch Apex job processed 5 batches with 0 failures.

 

Error I am getting is:

Update failed. First exception on row 0 with id 001Q0000005U7c4IAC; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, trigAccount: execution of BeforeUpdate caused by: System.Exception: Too many SOQL queries: 201 Class.AssetUtility.GetAssetsForAccount: line 109, column 30 Class.AccountUtility.ResetFlagOnUpdate: line 236, column 30 Trigger.Account: line 29, column 17: []

I have traced following things:  

Error record number on which I am getting error: 600

 

Total records to be processed :678

 

Query being used by Batch Apex:select Id, Number_of_Cases__c, Number_of_Contracts__c from Contact

 

This application has simple task to updat account records. Below is the code in the Execute call:

/* Execute : This function performs Batch Update process */ global void execute(Database.BatchableContext BC, List<sObject> scope) { /* Loop through each records list as per the Query paramater. Perform the updates */ List<Account> accountsToUpdate = new List<Account>{}; try { for(sObject s : scope) { Account a = (Account)s; if(blnIsIncludeNumberOfCases) a.Number_of_Cases__c = [select count() from Case where Account.id = :a.id]; if(blnIsIncludeNumberOfContracts) a.Number_of_Contracts__c = [select count() from Contract where Account.id = :a.id]; AccountsToUpdate.Add(a); iCountForAccount++; } //Update all accounts in batch update AccountsToUpdate; } catch(Exception e) { iErrorRecordNumber = iCountForAccount; strMessage = 'Error with Batch Apex : ' + e.getMessage() + '<br />Error record number: ' + iErrorRecordNumber; } } //End of Execute

 

This seems like Salesforce governance limit, bt I need to know how to overcome this.

  

Please help.

 

Regards,

Chandrakant M

  • October 30, 2009
  • Like
  • 0

I am using the below formula 

 

IF(ISBLANK( VALUE( Currency__c )), Amount_Spent__c, Amount_Spent__c * 50)

 

Formula return type is a number.  Currency__c is a lookup and Amount_Spent__c is a number field. For true ie if Currency__c is blank then it returns the desired value. But for an false condition it is returnin #error.

 

What is wrong with this formula can any one help me.

 

Regards

Sankar

  • October 20, 2009
  • Like
  • 0

I am new to Salesforce and need to create the following validation rule formula.  The formula requires a value in the case comments that matches the account name related to the case.  (i.e. if the case is assigned to an account named ABC, the user must enter the phrase "ABC" in the case comments for the entry to be valid.)

 

Please help!

  • October 19, 2009
  • Like
  • 0

Aside from the free app on appxchange, has anyone created/used/purchased an map building add-ins for salesforce? I'm looking to provide our sales teams with collaborative maps that are easy to use, visually helpful and customizable.

Any info would be greatly appreciated. 

Thanks,

RRC

  • October 19, 2009
  • Like
  • 0

Hello All,

 

I am looking to implement SSO for my organization, I need to give an estimate of the level of effort involved here.  Can anyone please provide me with some feedback around how long I can expect this to take either using the native WSDL file of SFDC or using an App like Ping Connect?  I am integrating with our LDAP.  Please help!!! Thanks much!  

 

I know it's unconventional but if someone who is experienced in SSO would be willing to have a 5 minute phone call I would be forever greatful!

Hi All,

 

I am facing problems with mass updates of records module design. I had to change my appl design in lot of way because of below scenario:

 

Scenario:

I need to update mass contact records based on filter criteria. Fields to be updated are the count of number of cases and activities against the respective contact records.

 

How it works:

I have a Visualforce page from where I call a method from the custom controller class.

 

This method queries on contact records based on filter criteria. Divide them into the quantitative batches. Collects a set of Ids for one batch and pass it to future method (asynchronous).

 

Issue:

1. Even though I am using future method, I get “Too many SOQL queries: 101” error.

I learnt that a future method allows me to work on 10,000 SOQL queries or DML statements (http://wiki.developerforce.com/index.php/Governors_in_Apex_Code).

 

Due to this, I can work only on a batch of 99 records.

Shouldn’t it be 10,000 SOQL queries which I can process in future method called through Visualforce controller?

 

2. If I activate trigger, this batch size is still decreased as execution of trigger also adds SOQL queries.

 

I don’t understand why execution of trigger adds SOQL queries to my future method limit. Even it adds to it, why it throws error after 100 SOQL queries? Also, I am also looking for an option by which I can stop trigger from being executed if I am updating records from my Visualforce controller. Having a flag field and check its value inside trigger work around is sarcastic.    

 

Please help. Salesforce looks quite intelligent to answer mass records updates requirement using future annotation but as I have experienced up to now, I can process only 700-800 records successfully not more than that which is simply not acceptable.

 

Regards,

Chandrakant M

machhi_c_m@yahoo.com

Message Edited by Machhi on 10-09-2009 12:27 AM
Message Edited by Machhi on 10-09-2009 12:28 AM
  • October 09, 2009
  • Like
  • 0

I know there is a wealth of information out here on this and I am studying, but I haven't figure it out yet.

 

Do I just need to use a loop like this?

 

 

for(List<Account> a : [select id from Account where IsDeleted=false]){delete a;}

 

 

 

Hi,

 

As you all know Salesforce is phasing out s-control next year, so I am given the task to convert one functionality written in S-control to VF page.

 

My object is select more then 10000 records from the object (lets say my object 30000 records). Even consider by applying all filter criteria SOQL still need to fetch more than 10000 rows.

 

But when I try to select more then 10000 records using SOQL, apex throw a limit exception to me.

So any idea how we can select more then 10000 records in VF/Apex solution.

 

Any suggestion is appreciable.

 

Thanks

Rajan

Hi,
 
    We are trying to implement SSO from our Intranet using the SalesForce Delegated authentication model.  We have covered a lot of steps and seems like are close to having this functionality but are running into the following issue -
 
    When the user clicks on GoTo SalesForce link from our Intranet, we receive the Delegated authentication callback and return true to validate the token.  Next, the users browser displays a blank page with a URL such as the following -
 
 
     It appears that the user session is established, because I can manually change this URL to https://na3.salesforce.com/home/home.jsp and the user is logged in.  But I am not sure how to make the browser automatically endup in this URL.
 
    Thanks for any suggestions,
 
Vijay