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

learn more… | top users | synonyms

0
votes
1answer
25 views

Dynamic SOQL multiple statements

My OR condition with in the where statement is failing to execute, Can someone let me know if I'm missing something or querying it wrong. Any help is much appreciated. SELECT Id FROM Object__c ...
1
vote
1answer
17 views

Query Records “where MyCustom__Date__c.Month()=1”

I want the records where MyCustom_Date__c month is = January. Where my field MyCustom_Date__C is formula field lst="select Name from CustomObj__c where MyCustom__Date__c.month() = : 1" Its giving ...
0
votes
0answers
9 views

Count stamp in a field

I have a requirement where there are custom objects like Incident_abv__c , Incident_Transaction_abv__c (child of Incident) , Incident_Transaction_Line_Item_abv__c (child of Incident Transaction). Now ...
0
votes
0answers
16 views

How to use SOQL to query Account IDs that has 0 records of a custom related object?

I'm trying to write a trigger that would count upon insert/update the amount of "Active_Competitor_Relationship__c" records that's associated with each account record. The problem is that when an user ...
0
votes
2answers
33 views

Dynamic SOQL ERROR: invalid operator on id field

I'm facing this problem while creating this query. String qry = 'select name, id, account__c from orders__c '+' where account__c LIKE \'%'+searchText+'%\''; searchText is declared as public string ...
2
votes
1answer
30 views

Pagination with Wraper class List

I have Wraper class list which holds list of Records form 2 objects. This list Iam using in Page block table to show the data from both objects. Now I have to work on Pagination. For Pagination we ...
1
vote
1answer
22 views

How can we add colon to a string value before dynamic soql query

I have a soql statement which is used to soql the result from a sObject but I need to mention the id in the soql how can add colon to the both side of id. my requirement SELECT Result__c,Notes__c ...
0
votes
0answers
21 views

Visualforce Error - Dynamic SOQL Binding

I have queried Account record using dynamic SOQL <apex:PageBlockTable id="tableid" value="{!lstAccount}" var="acc"> <apex:repeat value="{!lstField}" var="f"> <apex:column ...
3
votes
1answer
49 views

SOQL injection in dynamic query

I am facing soql injection issue in my dynamic query, i have done with sting.escapesinglequotes() also but still facing this issue. here is my code. query: query = 'select id,Name,Owner.Id from ' + ...
0
votes
1answer
14 views

Need to refer child objects records also in PDF

I have a requirement to display child object records also alongwith Parent records. Please find the below SOQL pattern. SELECT Name, Account_Abs_abv__c,Account_Location_abv__c,Attendee_Role_abv__c ...
1
vote
0answers
37 views

Nested Query error

I have below nested query where Line Item is child of Inc Transaction and all field names are valid still I am getting errored out Can someone please help me here? NESTED QUERY: select ...
0
votes
1answer
29 views

Relationship objects from the current object

I have 3 objects A, B and C. And B and C have lookup to A. I want to find all the objects which have lookup to the object A. I am able to get all the Child Relationships (using ...
4
votes
1answer
108 views

Query for a list of IDs using Dynamic SOQL from JavaScript

I'm trying to update multiple records and then send email notification using custom list button. For this I need to get few fields off the related list. One option would be traverse thru the related ...
3
votes
1answer
54 views

Efficiency when querying data with dynamic SOQL vs. formula fields

I am coding a search functionality where I have several parameters to search for (Account Name, Location Name, several kinds of dates, etc. My question is, when filtering the data in the SOQL query ...
1
vote
0answers
52 views

SOQL Injection Error in Checkmarx Scanner Report

I have a query similar to this in one of our apps, List<Account> accountList = Database.query('SELECT Id,Name FROM Account WHERE Id IN:accIds'); But Checkmarx always gives SOQL Injection ...
4
votes
2answers
52 views

Order Field by List in SOQL SELECT

I have an aggregate query on the Lead object. The query returns a list of Leads grouped by website (custom field) in a specific order based on a MAX of a date attribute. Say once we iterate through ...
1
vote
1answer
198 views

Getting error “System.LimitException: Too many query rows: 50001” what i do in this case.

i tried below resolutions but no any worked... REsolution: If your controller does not have any DML operation than you can easily solve above two salesforce governer limits using the attribute ...
10
votes
4answers
308 views

SOQL query to return records with numeric values

I'm trying to write a dynamic SOQL query to get an object's record that has numeric value in a particular field. I'm trying to do something similar like below: Account acc; queryString = 'SELECT ...
3
votes
1answer
79 views

Is it possible to get record data and SObject metadata in a single API call?

We're trying to handle custom fields for things like Tasks. Is there any best practice for doing things dynamically? We've made a webapp that lets users from various organizations connect. So it's not ...
1
vote
2answers
75 views

Accessing the fields of Database.query() results

Database.query(query) returns sobjects. I want to access each fields in this sobject to check the value on each field. How is this done in controller?
12
votes
4answers
743 views

Howto wildcard SELECT * to query all fields of objects in APEX?

I have created sObject and I need all the fields and I have many. Is there a way I can directly get all of them rather then typing each one of them.
1
vote
1answer
63 views

Offset value as a variable

I have to put an offset value in a query as a variable.Can someone please help here?Please my code snippet here. Integer lim=101; for(Integer i=0;;i+lim){ Integer j=i-1; return ...
0
votes
2answers
356 views

Apex CPU Time limit exceeded error

I have a batch apex class that is facing CPU time limit exceeded error. Can someone please help me to by pass this error here? Please find my batch apex here. global class Account_chk_batch ...
1
vote
1answer
51 views

Programmatically determine relationship between two sObjects and generate result

I have an application which allows the user to specify a geography object and field. For example User's country field Account's State Field Now for Leads the system needs to dynamically determine ...
2
votes
1answer
105 views

Dynamic SOQL for Cross-Objects

I am wondering if there is an easy way to dynamically query accounts based on the account having the primary FSE name attached to it. The Primary_FSE__c field is on the Installed Product Object, which ...
0
votes
1answer
106 views

query for multipick list values

I want write down query to fetch value depend on Channel. when user select Channel value is equal to Partner(pick list value) and then display value in dependent pick list for Partner Level which ...
0
votes
1answer
63 views

Not Queryable field issue

I have to query on a non-queryable field here. Can someone suggest a workaround for this? Please find my code below. trigger PM on Account (after update) { for ( Account acc : Trigger.New ) { ...
1
vote
2answers
131 views

After update trigger issue

Please find my code below. trigger PM on Account (after update) { for ( Account acc : Trigger.New ) { List<Product_Metrics_vod__c> listCon = [Select ...
1
vote
2answers
78 views

SOQL_SOSL Injection Issue Solution

Here I have done get;set; with "selectedEvent" which is a selected value of the Picklist, which can be TODAY, THIS_WEEK, THIS_MONTH or NEXT_MONTH which are standard things which I can use in SOQL to ...
3
votes
2answers
388 views

Grouping in Visualforce Charts

I have created a visualforce charting barSeries and it renders the results that I want aside from products with values of zero for the month. The chart is a repeat business report that is meant to ...
2
votes
2answers
139 views

How can I query parent to child with two child values and no other child values?

I have one parent "quote__c" and child object "Quote_line_item__c" .I want get the parent id with query some thing like this select id,(select name from quote_line_item__c where name='123' and ...
0
votes
0answers
73 views

how to get exact match of child records using a query?

I have Quote and Quote line items .Quote is parent and quote line items are child . I am developing one application . i am getting quote_line_item__c names as user input .I want to exact match of ...
5
votes
2answers
263 views

Apex CPU Time limit in Batch start() - is this a Query Timeout and how to cope with?

I have a Batch iterating over a large amount of records (with many fields) and 2 of their related child records. The start() method uses Dynamic SOQL to fetch them via QueryLocator to vary which ...
0
votes
1answer
90 views

How to dynamically assign objects in SOQL based on an event in the page?

Could you please help me on this? Existing Scenario: Records from two different objects ObjectA and ObjectB are displayed in a page as a news feed in ascending order of modifieddate. When click on a ...
1
vote
1answer
58 views

SOQL Includes with Field Value?

I'd like to add a FROM Account WHERE Clients_for_Job_Opportunities__c INCLUDES (AVTRRT__Job__c.Account.Name) line to my SOQL query but at the moment it looks like I can only add static values. So ...
2
votes
1answer
208 views

SOQL done right. SOQL-Injection secure

I was looking for some reassurance that all that needs to be done (and its best practice) when doing dynamic SOQL is to use escapeSingleQuotes. There was a query like this string query = 'SELECT ' + ...
0
votes
0answers
83 views

Issue in wrapper class

In the following snapshot we are fetching parent and child records using wrapper class.Selected child records should be displayed in selected course.But whenever i select child records only last ...
2
votes
1answer
225 views

Wrapper class Fetching all the Values

By using search function i need to fetch parent record and child record, the search function is happening in child record. Search function is fine But it is showing all child records in parent. this ...
2
votes
2answers
118 views

Passing array position as variable in dynamic SOQL

I want to pass a list position to my dynamic query, but it does not evaluate. have someone try something like this : ....... if(selectedType == Constants.settlementTypeAutre){ ...
4
votes
2answers
1k views

Concatenate fields in SOQL queries in the WHERE clause (no Apex)

I am trying to run SOQL statement in salesforce.schema tool of FORCE.COM the following query: Select c.LastName, c.FirstName From Contact c WHERE (FirstName+' '+LastName) In ('Good Name','Bad Name') ...
2
votes
1answer
128 views

How can I dynamically transverse dynamically SOQL'd SObject fields in Apex?

So, in my other post, I figured out for myself how to dynamically transverse SObject fields in Apex. But within the context of my work, there is a problem with the solution as it currently stands: ...
2
votes
1answer
820 views

Query Multi-Select Picklist in Apex with Visual Force Page

I'm having some difficulty figuring out the correct way to do this. If I have a visual force page with a multi-select picklist and I need to run the selected values through a query. The issue is I do ...
1
vote
1answer
286 views

SOQL for getting CaseComent for a case

I want to get the associated CaseComment's CommentBody for a list of cases. String queryFields = 'Id, Subject, CaseComment.CommentBody'; List<Case> cases = Database.query('select '+ ...
1
vote
2answers
906 views

get account name from a soql query on case

String queryFields = 'Id, AccountId, ContactId, type'; List<Case> cases = Database.query('select '+ queryFields +' from Case'); for(Case c: cases){ System.debug(c.AccountId); } Instead of ...
3
votes
2answers
782 views

Dynamic soql : Unexpected token '{'

Set<Id> sId = new Set<Id>{}; sId.add('a0df000000063A9AAI'); sId.add('a0df00000006P2cAAE'); String squery = 'SELECT Id, Name FROM Engagement__c WHERE Id IN:'+sId; List<Engagement__c> ...
3
votes
2answers
947 views

Dynamically create SOQL query from sobject

I have an SObject say Account which has some not null fields. I want to select all the accounts matching those values. Is there a way I can create a dynamic SOQL query for this. Suppose the Account ...
7
votes
2answers
618 views

How to execute a dynamic SOQL query with a variable number of “in” terms?

I understand from answers like this Bind variable with dotted name not working in dynamic SOQL that binding Apex variables into dynamic SOQL is more limited than into static SOQL. I want to write ...
5
votes
1answer
194 views

Soql-builder - Datetime issue

I have been trying to write a dynamic soql query by using soql-builder http://richardvanhook.com/2010/04/11/soql-builder/ But, I am stuck while assigning date as criteria while constructing the ...
2
votes
2answers
1k views

Line Breaks Not Allowed in String Literals

I have a SOQL query below that works in the Force.com Explorer but when I implement it into my dev org Visualforce page, I get the following result: Error: Line Breaks not allowed in string literals ...
1
vote
1answer
92 views

dynamic query to pass email field value

How to frame the below dynamic query. Opportunity_User__c field has value in format of "test@gmail.com". Now i want to retrieve all the opportunities having that value using dynamic query. ...