• AlexPHP
  • NEWBIE
  • 130 Points
  • Member since 2009

  • Chatter
    Feed
  • 5
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 26
    Questions
  • 52
    Replies

I'm trying to query something in a custom button JavaScript.  The query uses a reference field on the custom object record.  However the {!} returns with referenced object's name instead of id, so I can't use it in a SOQL statement.  For instance,with SFDC_Projects__c defined as a lookup/reference on SFL5_Time__c object,

soql=soql + "'{!SFL5_Time__c.SFDC_Projects__c}'";

gets 'steves project" instead of the id for the project.  Since I'm trying to find out another object that's related to the same project, I really need the id instead of the name.

 

The same way works just fine in APEX trigger.  What did I miss in the JavaScript/AJAX Toolkit environment?

  • August 02, 2010
  • Like
  • 0

Is there an remainder operator like % to get the remainder in a division? ex: 5%3 =2

 

Thanks

Ram

Hi,

 

wonder if you could help with the code below? we have a trigger that works unitl it hit the 20 query limit. I know that the logic need to be done out the for loop but not sure how to code it... can anyone help?

104 trigger FieldVisitTrigger on Field_Visit__c (before update) { if(trigger.isUpdate){ for(Field_Visit__c fieldVisit : trigger.new){ system.debug('############# Field Visit Before Update Trigger'); system.debug('############# Field Visit Validated Field = ' + fieldVisit.Validated__c + '#############'); system.debug('############# Field Visit ID = ' + fieldVisit.Id); String errMsg=''; List <Group> postcode_group_set=new List <Group>(); // Initialise list to contain any matches List <Group> postcode_matches=new List <Group>(); // Process only if Validated and Unallocated if (fieldvisit.validated__c && fieldvisit.job_status__c=='New PDV') { // Check for Site Postcode if (fieldvisit.site_postcode__c==null) { fieldvisit.addError(' No Site Postcode - Unable to assign to queue'); } else { // Calculate postcode prefix name details String postcode_prefix=fieldVisit.Site_Postcode__c.toUpperCase().replaceAll(' ',''); postcode_prefix=postcode_prefix.replaceAll('[0-9][A-Z]{2}$',''); // e.g. B23 String postcode_region=postcode_prefix.replaceAll('[^A-Z]',''); // e.g B // Set starting postcode e.g. B23_postcode_group String postcode_group_name=postcode_prefix+ '_postcode_group'; // e.g. B23_postcode_group // Set selection criteria e.g. All B postcodes with B%_postcode_group String postcode_group_select= postcode_region + '%_postcode_group'; try { // Get postcode list of all possibles postcode_group_set = [select id, name from Group WHERE type='Regular' and name like :postcode_group_select]; // while there are no matches (and there is a group set to check) while (postcode_matches.isEmpty() && postcode_group_set.size()>0) { // Search possible groups adjusting current postcode name postcode_group_name=postcode_prefix+ '_postcode_group'; // iterate group set looking for matches to current name for (group grp : postcode_group_set) { if (grp.name.equals(postcode_group_name)) { postcode_matches.add(grp); } } if (postcode_prefix.equals(postcode_region)) { break; } // reduce prefix e.g. B23 to B2 postcode_prefix=postcode_prefix.replaceAll('[0-9]$',''); } // Error checking if (postcode_matches.size()>1) { errMsg+=' Postcode group "' + postcode_group_name + '" - Duplicate group found.'; } if (postcode_matches.size()==0) { errMsg+=' Postcode group "' + postcode_group_select + '" - Not found.'; } // Get queue id for postcode group List<GroupMember> pg_member = [select GroupId from GroupMember WHERE UserOrGroupId =:postcode_matches.get(0).id]; // Error checking if (pg_member.size()>1) { errMsg+=' Postcode group "' + postcode_matches.get(0).name + '" - Assigned to more than one queue or group.'; } if (pg_member.size()==0) { errMsg+=' Postcode group "' + postcode_matches.get(0).name + '" - Not assigned to queue.'; } if (!errMsg.equals('')) pg_member=null; // Force error if error message // Get queue using queue id Group region_queue; for (GroupMember gm : pg_member) { Group g=[select id, name from Group where type='Queue' and id=:gm.GroupId]; if (g<>null) { region_queue=g; break; } } // Assign record to queue fieldVisit.OwnerId=region_queue.id; System.debug('############# Field Visit Owner Id Updated to ' + fieldVisit.OwnerId); // Move on job status (so future record updates will not trigger) fieldvisit.job_status__c='Issued to Field'; system.debug('############# Field Visit Job Status = ' + fieldvisit.job_status__c); } catch (Exception e) { fieldvisit.addError(errMsg + ' [Error for Site Postcode "' + fieldVisit.Site_Postcode__c + '"]'); /* + ' prefix:'+postcode_prefix + ' grp name:' + postcode_group_name + ' select:'+postcode_group_select + ' matches:'+postcode_matches + ' grp set:' +postcode_group_set);*/ } } } } } }

 

I have a custom objects that receives records from an external system.  When the records come in I want to assign them to a specific user to maintain security.  I believe a trigger would work best but have no experience creating one.  Can anyone help?
  • March 02, 2010
  • Like
  • 0

Note : Following is a small development being carried out to demystify salesforce apex webservice and callout features, please correct me if you find my understanding to be incorrect.

 

I am trying to integrate two Salesforce Orgs using Apex. Apex supports both callouts and webservices, then why not leverage both to achieve a 360 connectivity between two Salesforce instances.

 

Org1 : Create a Apex Web Service, Generate its WSDL

global class AccountPlan {

webservice String area;
webservice String region;

//Define an object in apex that is exposed in apex web service
global class Plan {
webservice String name;
webservice Integer planNumber;
webservice Date planningPeriod;
webservice Id planId;
}

webservice static Plan createAccountPlan(Plan vPlan) {

//A plan maps to the Account object in salesforce.com.
//So need to map the Plan class object to Account standard object
Account acct = new Account();
acct.Name = vPlan.name;
acct.AccountNumber = String.valueOf(vPlan.planNumber);
insert acct;

vPlan.planId=acct.Id;
return vPlan;
}

}

 

Org2:  Consume above generated WSDL to generate following Apex Class viz.,AccountPlanClasses

public class AccountPlanClasses {
public class LogInfo {
public String category;
public String level;
private String[] category_type_info = new String[]{'category','http://soap.sforce.com/schemas/class/TCSSAAS/AccountPlan','LogCategory','1','1','false'};
private String[] level_type_info = new String[]{'level','http://soap.sforce.com/schemas/class/TCSSAAS/AccountPlan','LogCategoryLevel','1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/TCSSAAS/AccountPlan','true','false'};
private String[] field_order_type_info = new String[]{'category','level'};
}
public class AllowFieldTruncationHeader_element {
............................
............................

 

Now lets try to connect to Org1 from Org2

AccountPlanClasses.Plan plan = new AccountPlanClasses.Plan();
plan.name = 'Chirag';
plan.planNumber = 111;
AccountPlanClasses.AccountPlan a = new AccountPlanClasses.AccountPlan();
a.createAccountPlan(plan);

 

Execution of above code runs into following error

WebService returned a SOAP Fault: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session faultcode=sf:INVALID_SESSION_ID faultactor= 

 

I to feel that somewhere I am missing User Credentials to be supplied, but I dont know exactly where. Please guide me to complete this 360 connectivity between two orgs using Apex.

Message Edited by Chirag Mehta on 05-05-2009 06:13 AM
Message Edited by Chirag Mehta on 05-12-2009 07:52 PM

Hi guys

 

I want to obtain an object field's ID.  This is the ID that identifies a particular field within an object.

 

I can see it in the URL link when I click on the field in the Setup, but is there a way to get it programmatically?  

 

I don't see it in the metadata that I get through the Force.com IDE.

 

Thanks

Is there a way to view what the limits are for a particular instance?

 

In particular, I want to know what my maximum Roll-Up Summary field limit is.  I know this can be requested to be increased by Salesforce, so the number for my instance may not be the default.

 

Thanks

When I query for a large double such as:

 

Select Id, Name From MyObject__c Where Custom_Double_Field__c = 2000000000

It works. 

 

 

But when I query for a larger number...

 

Select Id, Name From MyObject__c Where Custom_Double_Field__c = 3000000000

 

I get a MALFORMED QUERY error:

 

Query failed: MALFORMED_QUERY: where Custom_Double_Field__c = 3000000000

Error at Row:1:Column:65
For input string: "3000000000"

 

I'm not sure what the exact maximum number that it will take before it fails to work.  How can I fix this?  Do I need to cast the larger number in my SOQL?

 

 

Is there a way to make the URL content source (for links/buttons) not automatically encode the data coming from merge fields?

 

For example, if I have a field Foo__c that contains a URL 'http://developer.force.com' and I try to insert that into the URL content as a merge field:

{!MyObject__c.Foo__c}

 

The result is:

http%3A%2F%2Fdeveloper.force.com

 

Which causes a "URL No Longer Exists" error because salesforce is unable to redirect properly.

 

So, I'm wondering if there's a way to just treat the data literally in a URL content source.

 

Obviously there's workarounds to this by using OnClick Javascript as the content source instead of URL content source.

 

I'm looking for a method that will have a join/implode functionality.

 

I cannot seem to find an equivalent in the docs.  Does one exist in APEX?

 

Thanks

Hi guys

 

Is there a way to get user information from a session id?

 

I use a SFDC session id to initialize my PHP Toolkit.  After doing so, how can I get the username/user id/etc. about the user associated to that session?

 

Thanks

Hey guys

 

I'm a bit confused on how to properly use the class SObject (located in SforcePartnerClient.php) of the PHP Toolkit v13.  I couldn't find a sample code that utilize this, so hoping that one of you can point me in the right direction.

 

class SObject's constructor method signature is as follows:

 

public function __construct($response=NULL) {

So it seems like it should receive a a QueryResult response, but in actuality I think it is suppose to receive a response record (i.e. an SObject record).

 

However, if you look a bit further into the constructor of class SObject, you will see that it sets the Id to be the first element of the response's Id property.

 

if (isset($response->Id)) $this->Id = $response->Id[0];

 This seems to work for the older version of the PHP Toolkit (v11), because that version seems to return stranger response records, where Id would be an array of Ids...

 

[Id] => Array
    (
        [0] => a0F40000003l4ehEAA
        [1] => a0F40000003l4ehEAA
    )

 

 

But in version 13 of the PHP Toolkit, the response records are already SObject objects...

 

[Id] => a0F40000003l4ehEAA

and seems to make the use of class SObject obsolete?

 

 

Am I interpreting this incorrectly???  How do you properly use the SObject class?

 

Your input would be greatly appreciated.

 

 

 

Hey guys

 

I just created a new custom object in my sandbox, but it is not visible by other user profiles.

 

The custom object is set to Deployed status and Field Accessibility for the object is set to Read-Only/Required for all profiles.  The custom object is not visible via the APEX Explorer for other user profiles either.

 

Only the Sys Admin profile can see it.

 

Did I forget to set something?

Is there a way to automatically backfill an autonumber on existing object records?

 

Or does this have to be done programmatically via APEX?

 

Thanks for your insight in advance.

Does anyone know of the performance and limit ramifications between using __c vs using __r.Id when querying against reference objects?  They both seem to work, but what's the difference in terms of resource usage?

 

For example... 

 

// querying for myaccounts by a list of state ids

List<MyAccount__c> accounts = [ Select Id From MyAccount__c Where State__c In :stateIdsList ];

// VS

List<MyAccount__c> accounts = [ Select Id From MyAccount__c Where State__r.Id In :stateIdsList ];

 

 

We ran into a non-selective query issue and one of the things that seem to alleviate it was to switch a query from using __r.Id to use __c instead.  Therefore, I believe that using __c probably requires less lookups and will return a smaller set in the SOQL engine?

 

Anyone have any insight or know where there is some documentation on this distinction?

 

Thanks

I have a custom settings field where I store an object field id (15 character Id).

 

When using this custom settings field in an S-Control, it somehow automatically recognizes it is an Id field and adds the 3 character suffix to it!  This makes it the 18 character id.

 

Why is this and how can I fix that?  I do not want the 3 character suffix added automatically. 

Message Edited by AlexPHP on 03-15-2010 11:05 AM

Are custom settings not accessible via s-control and visualforce pages?

 

 

On the help page for Custom Settings, it says "you can access custom settings from formula fields, validationrules, Apex, and the Force.com Web Services API."

 

So if I wanted to use custom settings in an s-control, I have to make an API call?

 

Is there a better way to do this? 

 

Thank you 

Is it possible to use variables in the key of an INPUTS parameter of URLFOR?

 

For example, using a Custom Settings variable:

<apex:commandButton action="{!URLFOR($Action.MyObject__c.New, null, [$Setup.CustomSettingName__c.CustomFieldName__c=controllerClass.Id])}" value="My Button" title="Button Title"/>

 

As you can see, the action for the commandButton is the URLFOR the New functionality of MyObject__c.

 

I am trying to pass in an input parameter where the parameter key is a  Custom Settings invocation, and the value is my controller class's Id variable.

 

When I try to do this, the the Custom Settings variable is not evaluated, instead the button treats it as a string literal and directs me to:

 

 

 

%24Setup.CustomSettingName__c.CustomFieldName__c=a0MT0000002NnCnABC

It just encoded the '$' sign and didn't evaluate the variable.

 

How can I use a variable as the key in the inputs parameter for the URLFOR function?

 

Much thanks

Message Edited by AlexPHP on 03-09-2010 06:49 PM

I must be specifying a startDate for my replication functional call that's earlier than the enabled date and am getting this error:

  

INVALID_REPLICATION_DATE: startDate before org replication enabled date

  

How can I obtain the "org replication enabled date"?

Message Edited by AlexPHP on 03-05-2010 05:06 PM

We were developing on a trial instance, and just purchased platform licenses for our instance.

 

Upon doing so, all APEX Classes and Triggers were Inactivated.

 

This is a big mess now.  What can I do???

 

Thanks in advance. 

I can't seem to find documentation explaining why a trigger does not have the "Is Valid" flag checked on the Setup interface.

 

Can somebody shed some light on this or reference me to a resource explaining this?

 

Much appreciated. 

I developed some classes and triggers in my sandbox, the default API version is the latest 18.0

 

When I try to deploy these to my Proudction instance, it is telling me "Invalid api version: 18.0"

 

Why is that?  Is version 18.0 not available on my Production instance?  How can I tell if it is, and if so, how can I fix this?

 

Much thanks.

Is there a way to query for a particular user's "Recent Items" list?

 

That is, I want to be able to fetch a list of the last several records of a particular object that a particular user has viewed.

 

Thanks

Are the startDate and endDate that are supplied to the getDeleted/getUpdated API calls inclusive?

 

Meaning, a call to getDeleted will fetch any deleted records since the startDate INCLUDING on the startDate?

 

Thanks!

Hi guys

When I submit a custom object for approval, it does NOT prompt me for an approval comment.

On reassign, recall, approval, and reject actions it DOES prompt me for a comment.

How do I get the approval request submission to display the intermediary page to prompt the user for a comment?  Is there a setting for this?

Thank you!

Message Edited by AlexPHP on 11-20-2009 11:23 AM

I must be specifying a startDate for my replication functional call that's earlier than the enabled date and am getting this error:

  

INVALID_REPLICATION_DATE: startDate before org replication enabled date

  

How can I obtain the "org replication enabled date"?

Message Edited by AlexPHP on 03-05-2010 05:06 PM

Hi all

 

I am writing test cases for my Apex Page and want to verify that different messages are set at different points.

 

For this, I would like to clear out existing messages from my ApexPage.

 

Something similar to:

 

ApexPages.Messages = new List<ApexPages.Message>();


Is there a way to do this?

 

Hi guys

 

I want to obtain an object field's ID.  This is the ID that identifies a particular field within an object.

 

I can see it in the URL link when I click on the field in the Setup, but is there a way to get it programmatically?  

 

I don't see it in the metadata that I get through the Force.com IDE.

 

Thanks

Is there a way to view what the limits are for a particular instance?

 

In particular, I want to know what my maximum Roll-Up Summary field limit is.  I know this can be requested to be increased by Salesforce, so the number for my instance may not be the default.

 

Thanks

When I query for a large double such as:

 

Select Id, Name From MyObject__c Where Custom_Double_Field__c = 2000000000

It works. 

 

 

But when I query for a larger number...

 

Select Id, Name From MyObject__c Where Custom_Double_Field__c = 3000000000

 

I get a MALFORMED QUERY error:

 

Query failed: MALFORMED_QUERY: where Custom_Double_Field__c = 3000000000

Error at Row:1:Column:65
For input string: "3000000000"

 

I'm not sure what the exact maximum number that it will take before it fails to work.  How can I fix this?  Do I need to cast the larger number in my SOQL?

 

 

Is there a way to make the URL content source (for links/buttons) not automatically encode the data coming from merge fields?

 

For example, if I have a field Foo__c that contains a URL 'http://developer.force.com' and I try to insert that into the URL content as a merge field:

{!MyObject__c.Foo__c}

 

The result is:

http%3A%2F%2Fdeveloper.force.com

 

Which causes a "URL No Longer Exists" error because salesforce is unable to redirect properly.

 

So, I'm wondering if there's a way to just treat the data literally in a URL content source.

 

Obviously there's workarounds to this by using OnClick Javascript as the content source instead of URL content source.

 

Hi guys

 

Is there a way to get user information from a session id?

 

I use a SFDC session id to initialize my PHP Toolkit.  After doing so, how can I get the username/user id/etc. about the user associated to that session?

 

Thanks

Hey guys

 

I just created a new custom object in my sandbox, but it is not visible by other user profiles.

 

The custom object is set to Deployed status and Field Accessibility for the object is set to Read-Only/Required for all profiles.  The custom object is not visible via the APEX Explorer for other user profiles either.

 

Only the Sys Admin profile can see it.

 

Did I forget to set something?

Is there a way to automatically backfill an autonumber on existing object records?

 

Or does this have to be done programmatically via APEX?

 

Thanks for your insight in advance.

This error just started on a trigger that has been running perfectly for many months.

 

PaymentDuplicatePreventer: execution of BeforeInsert caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing. Even if a field is indexed a filter might still not be selective when: 1. The filter value includes null (for instance binding with a list that contains null) 2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times) Trigger.PaymentDuplicatePreventer: line 23, column 2

 

All this trigger is supposed to do is stop duplicates based on the unique code, which is just a formula field that combines two other fields on the record. Here is the trigger. It is pretty much copied exactly from the force.com cookbook about how to prevent duplicates. Any help is appreciated, thanks.

 

 

trigger PaymentDuplicatePreventer on Payments__c(before insert)
{
	//Create a map to hold all the payments we have to query against
	Map<String, Payments__c> payMap = new Map<String, Payments__c>();
	
	//Loop over all passed in payments
	for (Payments__c payment : System.Trigger.new)
	{
	
		// As long as this payment has a payment code and either it's an insert or it's doesn't conflict with another payment in this batch */
		if ((payment.UniquePaymentCode__c != null) && (System.Trigger.isInsert || (payment.UniquePaymentCode__c != System.Trigger.oldMap.get(payment.Id).UniquePaymentCode__c)))
		{
		
			// Make sure another new payment isn't also a duplicate. If it is, flag it, if not, add it
			if (payMap.containsKey(payment.UniquePaymentCode__c))
			{
				payment.UniquePaymentCode__c.addError('Another new payment has the same unique identifier.');
			}
			
			else
			{
				payMap.put(payment.UniquePaymentCode__c, payment);
			}
		}
	}
	
	/* Using a single database query, find all the payments in
	the database that have the same uniquepaymentcode as any
	of the payments being inserted or updated. */
	if(payMap.size() > 0)
	{
		for (Payments__c payment : [SELECT Id,UniquePaymentCode__c FROM Payments__c WHERE UniquePaymentCode__c IN :payMap.KeySet()])
		{
			try
			{
				Payments__c newPay = payMap.get(payment.UniquePaymentCode__c);
				if(newPay != null)
				{
					newPay.UniquePaymentCode__c.addError('A payment for this person in this study already exists.');
				}
			}
			catch ( System.DmlException e)
			{
				payment.adderror('Payment' + payment.UniquePaymentCode__c + 'Error ' + e);
			}
		}	
	}
} 

 

 

I've having trouble determining the combination of circumstances that are causing triggers cumulatively to exceed the 20 SOQL query governor limit.

 

I can't get a Debug Log for these because I can only request 20 debug logs at a time, and I do tens of thousands of transactions.  So I have no way of determining what combination of triggers and circumstances are causing the governor limit to be exceeded.  Furthermore, I can't even build my own debug log because database transactions and emails are rolled back when the governor limit is exceeded.

 

I have seventy some triggers on a dozen or so related objects.  A good portion of those potentially may need to make a SOQL query under certain circumstances.  A good portion may need to do a DML operation under certain circumstances.  They all work in batch, and if the circumstances don't seem to require the query or the DML I'm pretty good about not doing one to stay under the limit.

 

They are triggered by each of tens of thousands of transactions a day.  Maybe one or two of those exceed the governor limit even with a batch size of 1 for a certain object.  Many do with a batch size of 200.

 

I can log what data is being upserted, but I don't know necessarily know the exact state of the database in other objects or what triggers were fired because of these related records.  For example, I can know I posted a primary CSR to a quote, but I don't know that the primary CSR is changed, that it doesn't match the opportunity owner, or that the related order was priorly given credit to someone else.

 

Ideas?

Hi,

How do you send an email notification from Apex code? Please advice.

 

thanks

 

  • August 02, 2010
  • Like
  • 0

I'm trying to query something in a custom button JavaScript.  The query uses a reference field on the custom object record.  However the {!} returns with referenced object's name instead of id, so I can't use it in a SOQL statement.  For instance,with SFDC_Projects__c defined as a lookup/reference on SFL5_Time__c object,

soql=soql + "'{!SFL5_Time__c.SFDC_Projects__c}'";

gets 'steves project" instead of the id for the project.  Since I'm trying to find out another object that's related to the same project, I really need the id instead of the name.

 

The same way works just fine in APEX trigger.  What did I miss in the JavaScript/AJAX Toolkit environment?

  • August 02, 2010
  • Like
  • 0

This is more of a best practice type question. For a long time, I had a seperate testing class for every trigger/component/class. This got to be kinda bulky, and I found I was repeating a lot of code (lots of triggers revolved around creating the same types of objects, so many of my testing classes where essentially the same thing, save a few asserts). So I thought it would make sense to combine all my testing classes into one massive test class. Easier to maintain (from my point of view), and made it so I just created my test objects, ran my various asserts and coudl easily test all my code.

 

Now of course, that idea is failing. I have to create too many objects, and run too many different tests for them all to be contained in one file. But the fact that there is a lot of shared code is still true. So now I'm thinking about breaking it into testing classes by the object they test. I'm really fairly new to OOP, so I know there is a more eloquent way of doing it, probably creating some basic classes, and extend them for the various objects I need to test or something. Before I do another rewrite though I just wanted to see how the community does it. Thanks for any insight.

I have created a class that is called on the BeforeInsert trigger of Opportunity.  I would like to display an informational / instructional message on the standard Opportunity page when a record is successly inserted.   I know about adderror, but do not want the message to be displayed as an error.

 

Thanks,

Barb R.

Receiving this error:

 

Apex script unhandled trigger exception by user/organization: 00500000006r7X9/00D00000000havX

 

CopyContactDateToOppy: execution of AfterInsert

 

caused by: System.Exception: Too many SOQL queries: 21

 

Trigger.CopyContactDateToOppy.CopyContactDate: line 75, column 11

 

Here is the code...

 

 

Map<Id, Opportunity []> oppsMap = new Map<Id, Opportunity[]>();

//create list of related accounts and map them to the opportunities
List<Account> accts = new List<Account>{};
//this query below is line 75
accts = [select Id, (select Id from Opportunities where CloseDate > 2009-03-01)
from Account
where Id in:setAccountIdsSet and Id in (select AccountId from Opportunity where CloseDate > 2009-03-01)];

for (Account eachAcct: accts) {
oppsMap.put(eachAcct.Id, eachAcct.Opportunities);
}

 

What am I doing wrong here?

 

 


Hi,

 

We are getting the following error when trying to deploy a trigger.

 

 

ACCFTriggerValidation.myTest()Class773Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, tgrBatchJobs: execution of BeforeInsert caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com ...

 

The code snippet is attached. We are not sure why the batch upload fails and how we should index our fields. We are new to APEX so not sure how to get started.

 

// code snippet

//BATCH VALIDATION
      PreferredContact__c mycontact = new PreferredContact__c(Account__c=accounttest.id, preferredemail__C='user@site.com', preferredfax__c='3345567890');
      insert mycontact;
        
    PreferredIA__c testme = new PreferredIA__c(OKSendSurvey__c = true, account__c = accounttest.id, specialist__c = userid[0].id);
    insert testme;
    
    Batch_Job__c[] jobme = new batch_job__c[]{new Batch_Job__c(IsRunning__c = true, Description__c = 'test neutral', JobType__c = 'Test Email', DeleteMe__c = false),
                                           new Batch_Job__c(isRunning__c = true, Description__c = 'test positive', jobType__c = 'Send Surveys', DeleteMe__c = false),
                                            new Batch_Job__c(isRunning__c = true, Description__c = 'test positive', jobType__c = 'Send Surveys', DeleteMe__c = false)};
    insert jobme;
    
    jobme[0].Deleteme__c = true;

// error on line 77 column 3

    update jobme[0];
    
    jobme[1].Deleteme__c = true;
    update jobme[1];

  • July 09, 2010
  • Like
  • 0