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

learn more… | top users | synonyms

-1
votes
1answer
46 views

Dynamic SOQL Injection issue

Please let me know how to use injection for a dynamic query when there is no get/set for the individual fields in the WHERE clause.
1
vote
1answer
28 views

How to find a value in all column of an object?

How to find field_name/api_name name for any object that contains a value? I'm working on a object that has dozens of fields but I'm after finding out particular value belongs to which field name. ...
1
vote
2answers
22 views

SOQL - ignore custom field if non existent

I want to run a query like this - select id from lead where inactive__c = false limit 1 If the org doesn't have the custom field inactive__c, it throws an error. Is there any way to ignore the ...
0
votes
0answers
20 views

Hitting Governor limits because of the size of the single object being updated - is batch class the best answer?

I am new to SF apex coding. For legacy reasons we have a custom object that has about 400 numeric fields. We need to aggregate (sum) these 400 fields across different records into an aggregator ...
0
votes
1answer
23 views

List<id> at IN clause in Dynamic SOQl

I am fetching all the field from sObject and querying using Database.query(). When I query with List of id's it is throwing Invalid ID ('id', 'id', ...) error. for example at static soql we can query ...
7
votes
4answers
655 views

Genuine SOQL Injection issue or False Positive?

Trying to work out if this a valid issue with my code, or just a false positive I can note in report for Security Review. I have provided a slightly simplified version below. The Id I am querying for ...
-3
votes
2answers
40 views

Dynamic Search Function Test Method on QueryString

I am having a problem testing a queryString within a Dynamic Search function. For example, I have a list of strings related to Contact record. Within the VisualForce page, I run a Search Function to ...
2
votes
1answer
217 views

How to SOQL query contacts by phone number when there are more than 100,000 contacts

I am receiving a System.QueryException when searching for contacts by phone number in an APEX class: An error occurred at element myRule_1_A2 (FlowActionCall). An Apex error occurred: ...
1
vote
1answer
44 views

Get Network.getLoginUrl via SOQL dynamically

I would like to get the getLoginUrl information of a Network sObject. what is the be way to get this information dynamically via SOQL? since static methods can't be invoked dynamically. Thanks
-1
votes
2answers
43 views

How to count active workflows in one object

Requirement:-I need to count total Active workflows for each object . Like For account object how many active workflows are there.. Is there any quick way to achieve this(query or something like ...
3
votes
1answer
98 views

How to safely run User-generated SOQL query strings

Background Context: I'm building a small feature similar to Andrew Fawcett's Declarative Lookup Rollup Summary tool. We will allow users to enter in details for their own WHERE clauses for the ...
2
votes
3answers
187 views

Adding space in Dynamic SOQL

Can some one please to add the space before FROM in Dynamic SOQL. string query ='SELECT ' + qFields + 'FROM contact'+ ' WHERE user_num__c = \'' + ...
5
votes
2answers
202 views

Accessing child records returned from SOQL via generic SObject

I'm currently querying the records of a custom object, including some related child records. Unfortunately the parent object is unknown, so the returned results from the query is a list of SObjects. ...
-1
votes
1answer
45 views

i have records to be processed in vCommonRecords. i am not receiving the emails with expected results

My actual task is : 1.I have Account object it is having 2 child objects contacts and Orders. 2. need to process the account records with record type = Branch Integrated 3. need to send email ...
3
votes
3answers
96 views

SObject row was retrieved via SOQL without querying the requested field: Contract.Account

i'm trying to build query Dynamically for Contract object. public Contract con {get;set;} ConId=ApexPages.CurrentPage().getParameters().get('ConId'); Map<String,Schema.SObjectType> ...
2
votes
1answer
318 views

SOQL Dynamic Query building using Map.get(List)

I have a doubt. Suppose I want to query on Account object filtering based on a given list of IDs. Below snippet works fine when I have a list of Ids. List<String> accountIds = new ...
3
votes
1answer
55 views

How to use soql queries on multiple look up relationship object to retrieve specific data

I have 4 custom objects (as shown in the schema diagram). And they are associated using a lookup relationship. Now the objective of my question is to retrieve Product profile(product) for a given ...
1
vote
1answer
148 views

Select Count() with dynamic SOQL - how to stay in Governor Limits?

I am trying to fix my code so I don't hit any governor limits on my SOQL queries. Long story short: I am just learning on how to use maps, but I'm trying to figure out how I can do a SelectCount ...
0
votes
1answer
30 views

How to update the custom field using soql with limit?

I have to update Description__c field in Account object where BusinessUnit__c having BU1 to BU1000. I have the records BusinessUnit__c field contains BU1 to BU2000. I need to update Description field ...
0
votes
1answer
106 views

no viable alternative at character '\' dynamic soql issue

I have below method which gets called from page by supplying the search keywords: public PageReference runIntermediariesSearch() { soql = intermediariesSoql + ' where Name != null '; if ...
0
votes
0answers
121 views

Building Dynamic filters and displaying in VF page

I need to create a VF page(very simple). And i have a requirement where i need to build custom filter criteria in VF page on specific object(let's say Account).That's again not so difficult, As i can ...
0
votes
0answers
20 views

dynamically build a subquery [duplicate]

Setup: I have an Object Parent__c connected to Child__c . I have two relationships from Child to parent- mother__c , and father__c. In real life, these objects could be anything, so I need dynamic ...
2
votes
1answer
431 views

How to get data type of any object's field in SOQL

how to i get datatype of any filed in SOQL?
3
votes
2answers
577 views

isDeleted=True is not working in SOQL query

Wondering why this query will retrieve ZERO records when executed in Workbench and Developer console. (Though i have records in Recycle Bin) Select Id, IsDeleted FROM Account WHERE IsDeleted = TRUE ...
3
votes
2answers
210 views

BillingAddress in query generate error

I have a query like below in an Apex Class in Sandbox. query = 'SELECT Id, Name, BillingAddress, BillingLatitude, BillingLongitude FROM Account WHERE Name = \''+ name +'\' AND '; query += ...
0
votes
1answer
289 views

Dynamic SOQL for getting all objects in Salesforce Org

I am creating a VF page which contains a Picklist of all objects in my Salesforce org including Custom Objects. I am getting an error 'unexpected token: 'null' when I select custom object. VF Page ...
1
vote
1answer
64 views

Showing matching keyword sentences from SOSL/SOQL results

We have a requirement to search in large text area field (for e.g. Description). We are using SOSL for the same. While showing results on the VF page we want to only few sentence from Description ...
0
votes
1answer
96 views

Custom field visibility error on managed package installation

I have a managed base package and an extension package. The base package had a remote site as one of the components but I had to remove it. Since I couldn't remove the remote site from a released ...
1
vote
1answer
96 views

Transfer SelectOption Values to Dynamin Query

Trying to get the values to my Controller that I can change the limit on the displayed List on my Page. I'm Using a dynamic query and everything is working fine but what's below. What am I'm missing? ...
0
votes
1answer
151 views

How to search for text in Rich Text area field in Apex

i want to search a text in Rich Text area field in a custom object. As We can't use the RichTextArea field in where clause to search records,i am looking for the way to search a text. Is there any ...
1
vote
2answers
124 views

query as string type in controller class

Can any one explain me...what is the meaning of below lines. I get it from This link. String qryString = '<strong class="ph b">SELECT Id, title, UrlName, LastPublishedDate,LastModifiedById FROM ...
1
vote
1answer
288 views

Pass parameters from URL to SOQL query.

How can i pass parameters from URL to Controller? I want to pass URL parameters to My controller class where i can query to fetch data with the help of these parameters.
-1
votes
3answers
96 views

Trailing 12 Months Formula

All, **EDIT: Sorry for being too vague. I'm trying to add another field to my sales summary that displays on Account pages. I'm trying to grab the trades that fall within a date range of the past 12 ...
-1
votes
1answer
99 views

Count on sObject

EDIT: What I'm asking is, do I have to execute two separate query one for retrieving the information and one for count? is that possible to put both together in one query? in the .NET you just have ...
1
vote
2answers
68 views

common field between account table and contact table

I have Three questions 1.) Can you please let me know how to write a SOQL query to get the contact based on a specific record 2.)What is common column name between acount and contact table 3.)How ...
1
vote
1answer
158 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
88 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 ...
7
votes
5answers
868 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
85 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
61 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
237 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
56 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
384 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
260 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 ...
6
votes
1answer
327 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
187 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
41 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
381 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
311 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. ...
5
votes
1answer
463 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 ...