Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [dynamic-soql]

Dynamic SOQL refers to the creation of a SOQL string at runtime with Apex code.

1
vote
1answer
93 views

Create Dynamic Table On the basis Of 2 Objects [closed]

There are 2 objects one obj1 and obj2 I have to create dynamic table in visualforce page in which if new record is inserted to the obj1 then one row should be added to table and if one record in obj2 ...
0
votes
1answer
93 views

unexpected token found -null in dynamic query when i ran my test class

class method:- Error on this line lstofSobj = Database.query(query); -Unexpected token null public void deleteRecord(){ //system.debug('typeName::::'+typeName); ...
1
vote
3answers
3k views

System.QueryException: expecting a colon, found 'setids'

I keep getting the error: System.QueryException: expecting a colon, found 'setids' Why do I get this error? How can I fix it? public Database.QueryLocator start(Database.BatchableContext context) ...
-1
votes
1answer
340 views

Warning when using fflib_QueryFactory

When performing a sub query, I get the following message: WARN|fflib_QueryFactory.subselectQuery(Schema.SObjectType) is deprecated and will be removed in a future release. Use fflib_QueryFactory....
4
votes
2answers
287 views

Record Not Returned in Query in Managed Package

I think I'm going to have to find someone internal for this one, but posting to see if anyone has any ideas about this at all. The Problem We've got code in a managed package that's querying for ...
0
votes
1answer
552 views

soql query on case

I actually need a soql query to fetch those case records in which the incoming emails from email to case are more than one in the related list of case. One criteria is that the subject of the email ...
0
votes
1answer
2k views

Escape Sequence Single Quotes Error

I am creating a dynamic query. string s = '%' + searchText + '%'; string query = 'Select name, ShippingCity, ShippingState, ShippingCountry, rating, type, Industry, ownerId From Account Where name ...
1
vote
2answers
443 views

unexpected token: IN in dynamic soql

I have written a code which will give my dynamic soql and using this soql my execution will work. But i am getting this erro unexpected token: IN41 Below is my code Code public class ...
0
votes
3answers
195 views

Dynamic query Help?

I have created a custom Setting as "ContactSetting" and one field as "Agents_Field_Name" So my custom setting is like: Name:FirstName Agents_Field_Name:FirstName I am trying to query Contact record ...
1
vote
1answer
38 views

Capturing the Lead deletion log using dynamic apex

I am trying to create an entry in the deletion_log__c object before the lead record gets deleted. I would like to capture all the lead field names along with values in the deletion_log__c object with ...
0
votes
1answer
132 views

Risks of replacing SOQL query with QueryLocator [duplicate]

I used to have this block of code in a widely used method: SObject[] ls = Database.query(q); SObject[] children = new SObject[]{}; for (SObject l : ls) { for (SObject c : l.getSObjects('...
3
votes
2answers
382 views

Inconsistency with error “Aggregate query has too many rows for direct assignment”

I have a Box__c record with 100 Doors__r, 104 Motors__r, and 0 Wheels__r. ISSUE #1 I am getting the error System.QueryException: Aggregate query has too many rows for direct assignment, use FOR ...
0
votes
1answer
65 views

save error :unknown property 'DataInsert.fields'

Here is my apex class: global class DataInsert { // property declarations Set<String> fields ; global PageReference doInsert() { // other logic ...
0
votes
3answers
64 views

How to separate the required fields from Custom Object record?

I'm posting this question previously but i'm not achieving my goal for that i posting again I have a custom object called Incident__c. and it has some fields Imtpact__c Incident_state__c ...
1
vote
2answers
224 views

Query if Lead not modified in the current month?

Is there a way to query if a Lead has not been modified in the current month by using LastModifiedDate?
-2
votes
2answers
634 views

How to search a custom object using one or more input pick list fields from a VF page and display the result(s) in a pageBlockTable

accept the input as strings (in an extension), build & execute the query, populate a list element, display the list. Please give an example.
4
votes
2answers
1k views

Dynamic query in a for loop

I need to retrieve the CreatedDate of the last record creates of every custom object. But the only way I find to do it is by doing a dynamic query in a For or loop. But I’m, of course, limited to 100 ...
2
votes
2answers
562 views

Variable text string for SObject get method?

I want to use a variable string rather than a hard-coded string in my get method. For example, for every Field in Object A there will be a record in Object B and the record name is the field api name ...
4
votes
1answer
355 views

Is IN operator equivalent to Equal operator in SOQL when binding a list variable?

While testing some SOQL queries I noticed that the Equal operator behaves like the IN operator when using a list bind variable All the queries below run without any error and return the same result ...
6
votes
3answers
2k views

Possible to use bind :variable inside SELECT clause?

I cannot use the String[] ss inside the SELECT statement. It is giving me errors: unexpected token: ':' Code public void getSubscribers(Id listId){ String[] ss = new String[]{'Id', 'Name'}; ...
1
vote
1answer
497 views

Unexpected token '(' error batch apex

global Database.QueryLocator start(Database.BatchableContext BC) { String query = 'select id,ParticipantName__c,EpisodePoPEndDate__c from BPCIAe__c where id in :CHildParentMap.keyset() OR id in :...
22
votes
1answer
506 views

SOQL bind variable scope behavior

After I posted this question, I found a similar post that seemed to answer it: Variable scope - database.query() has access to variables not in scope. I'll leave this in place for now, as I am not ...
4
votes
2answers
2k views

Bind a List variable in a Dynamic SOQL Query

Code 1 List<String> accNameList = new List<String>{'Acc1','Acc2','Acc3'}; List<Account> accountList = Database.query('SELECT Id FROM Account WHERE Name IN:accNameList'); Code 2 ...
0
votes
0answers
37 views

“System.LimitException: Too many SOQL queries: 101”

I have SOQL on 17 objects to delete sharing Need help since we cant use SOSL on _share__c objects list<Lease__Share> deleteLeaseShare = new list<Lease__Share>([select id from Lease__Share ...
2
votes
2answers
1k views

Query sObject type with dynamic name

Can I create a list variable dynamically in Saleforce? Like this: String objectName = 'Noise_Dictionary__C'; List<ObjectName> lstObject = new List<ObjectName>([select id from ObjectName ...
0
votes
1answer
157 views

How to remove the query size limit for VF page

I'm using standard set controller, with dynamic search options on VF page. Now soql limit 1000 it works perfect. But i've to remove the soql querye limit. I.e. I can be able to fetch 70000 record ...
1
vote
1answer
232 views

SELECT ActivityHistories For Any SObject

I am writing a code which supposed to process a list of ActivityHistories for any SObject which supports them (like Opportunity, Account, etc). And at that point it's impossible to know what is the ...
0
votes
2answers
174 views

How to use list index in Soql

list<string> lst=new list<string>(); lst.add('name'); system.debug('lst[]'+lst[0]); system.debug([select count() from account where lst[0]!='' limit 1]); I am getting below error Line:...
4
votes
1answer
1k views

Check if an SOQL query is valid without actually executing it

I'm building a system where a user will be providing me with a query through a UI. This query will then be used in an Async Apex Job, by passing it as a param to Database.getQueryLocator in the start ...
0
votes
2answers
679 views

How do write a SOQL join between contact and custom object?

I need to get contacts with related table "Candidate_Farm_Assignment_c", the thing is i want that it will pull only the records that have a specific value from "Candidates_Farms_Assignments" SELECT ...
0
votes
2answers
23 views

Error: dailyHLAReportDashboardController Compile Error: expecting a right parentheses, found 'Active' at line 6 column 201 [duplicate]

I am trying to query counts of an custom object records but i also need to filter out the records. so when i am using single quotes for where clause getting error as: Error: ...
4
votes
2answers
1k views

Dynamic Query / escapeSingleQuotes And “no viable alternative at character '\'”

Read all the articles, tried most everything but cannot find a solution other than faith that users will not enter malicious data but: I am trying to create a user entered query filter but when I use ...
0
votes
1answer
237 views

Dynamic select KnowledgeArticleVersion by Language

I have the following code: List<KnowledgeArticleVersion> articles = [SELECT Title, UrlName, FirstPublishedDate, Summary, ArticleType, LastModifiedDate FROM ...
0
votes
2answers
76 views

Soql query is not displaying the values of the Child object record

I have soql query which will have subquery to get the value of the child object values. However there is no error in the query but the values that suppose to display is displaying as null in VF page. ...
2
votes
1answer
301 views

Select names of multiple sObject types in one query

I have a set of record id and I don`t know types of this records. Can I select only field name for this record ids in one query? I thought something like that: List<ProcessInstanceWorkItem> ...
0
votes
2answers
1k views

How to query multiple Child object of a parent in single soql query

I have to bring the values of a multiple child object of a Parent object in single query, I tried the following method , however for query one child object as a first step it throws me the following ...
0
votes
1answer
58 views

Performance issue for searchable 500+ fields

I haven't work on something like this before but what are the performance implication whether using SOQL or SOSL 500 fields+ (fields will be added dynamically as the application grows) and having 800K ...
0
votes
2answers
74 views

how to build dynamic query

Hi I have to query a record information of the customer. Based on the number of Order the customer submits it should retrieve the same. Please find my query below In the above code i am using the ...
0
votes
1answer
347 views

Variable does not exist: portalUserInfo.conAccount.Id in Query

Please help with this error: String query = 'SELECT Project__c,' + ' Project__r.Testing_Submitted__c,' + ' Project__r.Project_Sub_Phase__c,' + ' Project__r....
2
votes
3answers
2k views

Dynamic SOQL query

I'm trying to build a dynamic query but I think I may have the wrong syntax. String query = 'SELECT ProjectId__c from Project__c' projectList = Database.query(query + ' WHERE Name__c equals 'pp2'); ...
0
votes
3answers
167 views

Dynamic Field Query error from non sys admin users: unexpected token: 'from': ()

I am trying to clone a record and dynamically query all fields. This works fine for system administrator but something is going wrong for non system administrator users trying to trigger the logic. ...
3
votes
1answer
294 views

SObject row was retrieved via SOQL without querying- Using Dynamic References

I am referring to a code from salesforce documentation https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_dynamic_vf_sample_standard.htm where it is shown how to build a list ...
2
votes
3answers
751 views

Using a variable after FROM in SOQL statement

I am building a custom VF component where I have an attribute which of type Object. I use this attribute to query first 10 records and display it using pageblocktable. The user can provide any object ...
0
votes
1answer
37 views

How can I query email field by comparing the date field?

I want the emails from contact where due_date__c is less than 15 days and 1 day. Select id, email from user where Contact.AccountId in (select Location__c from Grant_Schedule__c where ...
0
votes
1answer
41 views

label value inside another label

There is a label label_query which contains the SOQL query say 'Select name from Account where recordtypeId = 'value coming from another label'. In another label is stored recordtypeid. Now to use ...
2
votes
2answers
2k views

Dynamic Query - System.QueryException: expecting a colon, found '.'

Suppose I have one code, HI, which is mapped to these values: HIRT, HIFS,HISL,HIST,HIGC,HIAN,HIIS,HICV,HISR,HOLI. When I select HI those values are are passed into a dynamic soql query. For a small ...
0
votes
1answer
502 views

Convert lead failure- Cannot update converted lead?

Line: 128, Column: 1 System.DmlException: ConvertLead failed. First exception on row 70; first error: CANNOT_UPDATE_CONVERTED_LEAD, cannot reference converted lead: [] Got above Error from Below ...
2
votes
2answers
272 views

Using wildcards for column names in dynamic soql in apex

I have a scenario where my columns names can be of form genesis__prod__c/docgen__prod__c/lnd__prod__c,etc depending upon which package is using my solution package. Here genesis, docgen and lnd are ...
0
votes
1answer
347 views

Creating a dynamic SOQL query using a MAP referencing different sObjects?

So I have the below code: Map<Id, String> sMap = new Map<Id, String>(); for(CKSW_BASE__Service__c s : Trigger.new) { if(s.VS_Site_Survey__c != null) sMap.put(s.VS_Site_Survey__c, '...
0
votes
3answers
68 views

dynamicSoql query

public class query { public string accname{set;get;} public string accindustry{set;get;} public list<account>account{set;get;} public void result() { account=[...