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

learn more… | top users | synonyms

1
vote
2answers
23 views

Updating the owner of records connected via lookup relationship

I was given a task to write a trigger to update the owner of records connected via lookup relationship. Consider i've a custom object which is having a lookup relationship to another custom object. ...
4
votes
1answer
73 views

How to use dynamic SOQL to instantiate a MAP

I've tried doing it, but I get this error: Compile error at line 101 column 32 Invalid initial type List<SObject> for Map<Id,Opportunity> Here's my code: //build out the set set ...
0
votes
1answer
28 views

Multiple LIKE in SOQL

I have a batch class where I need to find all contacts with titles like director, cEO, etc. This should allow partial matches such as 'support director', 'sales director', I was trying this but is not ...
0
votes
1answer
11 views

Dynamic SOQL - Risks/Impacts

I understand SOQL is a much restricted version of SQL but what are the potential risks associated with using dynamic SOQL? What damage could be done with malicious intent through it? I'm just trying ...
0
votes
1answer
32 views

Sorting functionality using dynamic soql

I have created a visual force page in Account page that displays related opportunities by RecordType(5 Records at a time) for the given Account and when click on Go to List it directs to new VF page ...
0
votes
0answers
36 views

Error as MALFORMED Query in Developer console (Group by Rollup, Group by Cube)

Why do I get this ERROR as :MALFORMED Query in Developer console? I'm trying to use :Group By Roll or Group By CUbe to get the subtotals and grand totals. When I tried this Query: SELECT ...
0
votes
2answers
24 views

Not able to query on standard Asset field 'ProductCode' . Please suggest

List<Asset> lst= [select Id, ProductCode, Product_Family1__c, Product_Family__c from Asset WHERE AccountId = '0015000000IBGof' AND ( (NOT IB_Status__c Like '%eval%') ...
0
votes
0answers
43 views

System.QueryException: Non-selective query against large object type with 0 records

I am getting the following error for a query I am running dynamically System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or ...
1
vote
1answer
23 views

How do I know which objects can use FOR VIEW/REFERENCE?

I'm implementing a custom UI for Salesforce using Visualforce and Remote Actions. When I'm displaying a specific record, I look for all visible fields and display it on the screen. The code in the ...
0
votes
2answers
41 views

Convert dynamic soql to static soql

I want to make the following dynamic soql to static soql. I'm a bit confused as I haven't done anything like this before. How can it be done? Any help on this would be appreciated. Thanks in advance! ...
0
votes
2answers
19 views

SOQL embedded select question

In our implimentation an Opportunity has a *.1 relationship with accounts and a *.1 relationship with brokers. An account is an entry to Object Account with Type = 'Customer'. A broker is an entry to ...
0
votes
0answers
39 views

Urgent Issue on Custom Settings

I've a Custom Settings with Hierarchy, on that two fields Read__c, Unread__c. integer i=10; integer j=5; query1='select id,name,is_read__c, (select id from Attachments where createddate ...
0
votes
0answers
29 views

How to feed a junction object, with a trigger using soql, and involving multi-select picklist

here is the situation: I have a custom object which is a database of apartments for rent (Appartment__c). Fields include the format (1-Bedroom, 2-Bedroom, etc), the rental price, an availability ...
1
vote
1answer
48 views

How Get Parent Field in Attachment?

Please Help me... Account sObject is Parent of Attachment. Now I want to bring Read-only Field Custom field (isReadOnly__c). SELECT Id, Name, Account.isReadOnly__c FROM Attachment How It Gets ? ...
0
votes
1answer
40 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
19 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
28 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
91 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
58 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
45 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
38 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
59 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
17 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
44 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
37 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
196 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
98 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
1answer
83 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
59 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
527 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
411 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
94 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
297 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?
13
votes
4answers
1k 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
75 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
477 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
57 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
131 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
138 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
68 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
144 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
93 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
522 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
166 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
88 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
335 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
95 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
67 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
293 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 ' + ...