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

learn more… | top users | synonyms

1
vote
1answer
24 views

I am getting Error “ Variable does not exist: queryResult”

Please Find the code <apex:page controller="SOQLController" > <apex:form> <apex:outputText value="Enter Name" /> <apex:inputText value="{!name}" /> ...
2
votes
1answer
17 views

custom setting SOQL vs methods

i often come across scenarios where we have some custom setting with lots of fields created which has rows for multiple purposes. So for a specific scenario, it is often needed to filter all the rows ...
3
votes
5answers
572 views

What's wrong with this SOQL

Declared a string and assigned SOQL value as shown below. While running I am getting an error. String country = 'United States'; String accountQuery = 'SELECT Id,BillingPostalCode,County_Name__c '+ ...
2
votes
1answer
18 views

How to filter query for specific types of parent lookup?

String query = 'SELECT Id, isDeleted, LastModifiedDate, parentId FROM Attachment WHERE isDeleted = true AND LastModifiedDate >= :timestamp ALL ROWS'; for (SObject deletedObject : ...
1
vote
1answer
41 views

unexpeced token: ( with dynamic SOQL

The following gives an error on runtime: String queryString = 'select name,street_address__c from warehouse__c where' + 'DISTANCE(location__c,GEOLOCATION('+ lat + ',' + lon+ ' ),\'mi\') ...
1
vote
1answer
56 views

query sObject or Custom setting by multiple fields

i need to implement logic at couple of places which is like querying an sObject or a custom setting. There are input fields using which i need to create filter criteria to reach appropriate records in ...
0
votes
1answer
36 views

Retrieve earliest record from each Grand child object

I have 3 objects, Object A, Object B and Object C. Object B is a child of Object A, while Object C is a child of object B. I am trying to access the all the single earliest records of all records in ...
1
vote
1answer
42 views

What meant by DescribeFieldResult Class?

Can anyone clearly explain what exact use of DescribeFieldResult Class in Apex code. And also please provide an example.
1
vote
1answer
115 views

Getting SOQL/SOSL Injection error when I send my code for security review

I have send my code for security review I am getting error for SOQL/SOSL Injection. I have made the changes on the bases they have mention in report. But even I am getting issue with dynamic soql I am ...
5
votes
1answer
68 views

Force Dynamic Soql results to include fields with null value

So I've read a lot about this and it seems that queries run with Database.query(queryString) will skip over any field values set to null instead of returning the property set to null This has cause a ...
0
votes
1answer
32 views

How to fetch the Account Name By selecting contact Name in custom object( communications__c)

I have a 2 fields in Communication__c (Custom object). field 1: Select_Contact__c (Lookup) (from Contact Object) field 2: Account_Name__c (Text). In Visualforce Page, when ever user selects the ...
0
votes
0answers
26 views

Pass Field Api From Visualforce Page to Controller

Hi everyone I have a scenario where I can select the fields and that can be either multiplied/subtracted/added/divided and that result should be updated in another field. Using describeobject class ...
2
votes
1answer
80 views

How to get Cases, Opportunities, Contacts Associated with Account Object Dynamically?

I need to get all the associated Contacts,Opportunities and Cases, for a given Account, if there are any. Right now, I am doing something like below: public List<Case> getCases(SObject sobj){ ...
1
vote
2answers
47 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
106 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
35 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
18 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
58 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
47 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
52 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%') ...
1
vote
1answer
133 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
31 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
48 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
26 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
42 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
47 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
83 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
47 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
21 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
10 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
35 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
191 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
75 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
73 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
55 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
78 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
21 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
55 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
43 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
293 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
174 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
110 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
69 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
822 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 ...
11
votes
4answers
588 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
105 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
584 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?
15
votes
4answers
2k 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
89 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
644 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 ...