You need to sign in to do that
Don't have an account?
Love SFDC
SOQL query exceeding the 20000 character limit - workaround
Hi everyone !
I'm looking for some good design practice for the below scenario.
I've an object which has lot of fields and a record is being created/updated in one of the class (say mainClass). Query in the mainClass is going to exceed
20000 characters which is the max limit of SOQL query. We're going to add few more fields in the near future and definetely the query size exceeds the
max limit. I can create a query2 for the same object, but the issue is to leverage the doSOmething() in the Helper class, which has lot of business logic in it.
How can I leverage my doSomething() method in this situation.
Any pointers on this is much appreciated.
public class mainClass {
public void sampleMethod1(){
Object1 query1 = [SELECT field1__c,field2__c,field3__c,field4__c,......
.......
.......
FROM Object1 LIMIT1]; // This query is GOING TO exceed 20,000 characters which is the max limit for a SOQL query in Salesforce
query1.field1__c='test1';
query1.field2__c='test2';
Helper hlp = new Helper();
hlp.doSometing(query1);
update obj1;
}
}
public class Helper{
Object1 o1;
public Helper(){
o1 = new Object1();
}
public void doSomething(Object1 obj1){
o1=obj1;
o1.field3__c = 'test3';
o1.field4__c='test4';
o1.field5__c='test5';
.
.
.
.
.//lot of business logic exist here to map the Object1 fields
.
.
.
}
}
I'm looking for some good design practice for the below scenario.
I've an object which has lot of fields and a record is being created/updated in one of the class (say mainClass). Query in the mainClass is going to exceed
20000 characters which is the max limit of SOQL query. We're going to add few more fields in the near future and definetely the query size exceeds the
max limit. I can create a query2 for the same object, but the issue is to leverage the doSOmething() in the Helper class, which has lot of business logic in it.
How can I leverage my doSomething() method in this situation.
Any pointers on this is much appreciated.
public class mainClass {
public void sampleMethod1(){
Object1 query1 = [SELECT field1__c,field2__c,field3__c,field4__c,......
.......
.......
FROM Object1 LIMIT1]; // This query is GOING TO exceed 20,000 characters which is the max limit for a SOQL query in Salesforce
query1.field1__c='test1';
query1.field2__c='test2';
Helper hlp = new Helper();
hlp.doSometing(query1);
update obj1;
}
}
public class Helper{
Object1 o1;
public Helper(){
o1 = new Object1();
}
public void doSomething(Object1 obj1){
o1=obj1;
o1.field3__c = 'test3';
o1.field4__c='test4';
o1.field5__c='test5';
.
.
.
.
.//lot of business logic exist here to map the Object1 fields
.
.
.
}
}
Thanks for the response. Can you pls throw some light on that. If possible, what method of SObject should be used. An Example of the scenario will be great.
Thanks,