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

learn more… | top users | synonyms

3
votes
2answers
37 views

How to find parent records with only 1 child record

I want to pull all the parent records which have only 1 child record either using a query or report or any other way. For example all the accounts with only 1 contact record. I don't want to create ...
0
votes
1answer
28 views

Database.Query() method casting issue

I am trying to re-word this code in a custom controller: public Double getFebruary() { Double amountX = (Double)[SELECT SUM(Amount)amt FROM Opportunity WHERE RecordTypeId =:oppNBRecordTypeId AND ...
11
votes
4answers
270 views

How to find out if an Object is a collection or single value?

I have some dynamic SOQL code in which I'd like to identify whether a method argument is a collection or a single value: SObject[] query(SObjectType sobType, String field, Object data) { // Want ...
2
votes
2answers
24 views

Query on parent child related objects in Salesforce

There are 2 objects Account & Address and their relationship is master detail. In address there is a checkbox called primary and most of the accounts will have 1 address which is marked as ...
0
votes
1answer
23 views

SOQL add dummy column

Is it possible to create dummy column while fetching in SOQL Like select 'Dummy Column Text' as DUMMYCOL from MY_TABLE
2
votes
2answers
36 views

SOQL Query: Stored XSS Error

I have given my code for Security code Scanner but it is given the following error due to Query: Stored XSS My query is like this. loan=Database.query('SELECT Name, fintechLLC__Application__c, '...
2
votes
2answers
68 views

Dynamic SOQL - issues in managed package

1) When Querying namespace_X__object1__c like so: namespace_X__object1__c sm = Database.Query('Select Id, Name, Security_Description__c, product_type__c from namespace_X__object1__c where id=:...
0
votes
1answer
29 views

Facing problem for a Group by multiselect picklist

I have a multiselect picklist called status with 3 values and 5 amount fields..The problem that i am facing is that whatever value i select from status,My code is grouping by for all 3 values. For e....
0
votes
1answer
31 views

Need guidance for using Group by clause in apex class

I am newbie so for the first time i am using group by clause.But i am not getting where i am going wrong. I have a VF Page where there is a status field which is a multi-picklist and a record type ...
1
vote
1answer
23 views

how to specify dynamic query field values to custom setting fields?

I have a dynamic query which has the where condition like this: ' WHERE (Contract_State__c=\''+'Complete Activated'+'\''+'OR Contract_State__c=\''+'Partially Terminated'+'\''+')'+' AND ...
0
votes
1answer
28 views

Using variable in Query

Can I use variables for objects in my SOQL query? I have the variable like: public sObject objectvar; Which gets a record of type Account. How can I use this variable in my SOQL query like: Select ...
0
votes
1answer
34 views

List Result is null

StaticResource sr = [select body from StaticResource Where Name = 'kalpak']; String contents = sr.body.toString(); LIST<String> alOne =new LIST<String>(); List<String> arrrrr = ...
0
votes
1answer
32 views

SOQL Dynamic Query on objects ( Dynamic sobject name in soql )

String str = 'Order'; List<SObject> listData = [Select Id From str ]; Can we query like this, I want to query dynamically
3
votes
1answer
218 views

Dynamic Visualforce page not showing Checkbox values correct after page reload

I have the following Visual force page: <apex:form id="mainForm" > <apex:actionFunction name="renderConsolePage" action="{!renderConsolePage}" rerender="out1"/> <apex:...
0
votes
2answers
64 views

Retrieving Dynamic SOQL results. Runtime error - “Invalid field Owner.Name for…”

I had a question in regards to dynamically retrieving the results of Dynamic SOQL that I have set up in my controller. I want to be able to access fields on the Lead object (Lead.Name) itself as well ...
0
votes
1answer
23 views

Getting compile error while creating dynamic SOQL

queryStr+ = 'AND Sales_Order__r.sales_year__c =' +\'' +:strYear+\''; This is my string.strYear is the year value which i want to add dynamicaly. I am getting an error "Compile Error: unexpected ...
0
votes
1answer
61 views

How to Format the numbers entered in the Input Text Fields

When i try to search with 1000000 and 1500000 in Price Min and Max fields.the soql query is executing fine.but when i enter the values seperated with commas like SFmin=10,00,000 and SFmax=15,00,000....
1
vote
1answer
33 views

A brief about Dynamic SOQL concept

can you give a complete manual/page for referring Dynamic SOQL where as https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dynamic_soql.htm never providing considerable ...
0
votes
0answers
20 views

use dynamic mapping object for web service

i am trying to write a GET web service to fetch a parent object say delivery and its child say delivery line. This is my first experience with web service.and the requirement is like i have to write ...
6
votes
3answers
333 views

Why I can not use Map in dynamic query

Map<Id, Account> maps = new Map<Id, Account>(); for(Account acc : [Select Id from Account]) { maps.put(acc.Id, acc); } String s = 'Select Id from Account Where Id IN : maps.keySet()'...
0
votes
1answer
86 views

Dynamic Query String Where clause concatenation

I am newbie & trying to create a dynamic querystring on the basis of some conditions, & even when it does not satisfies any condition, the query should be able to run properly with where ...
1
vote
3answers
88 views

Upsert failed in apex

I'm trying to do upsert and I get duplicate error on Unique field. Shouldn't upsert take care of whether to update an existing record or to add a new record? Error: caused by: System.DmlException:...
6
votes
1answer
227 views

Undelete error: entity is deleted

I'm trying to undelete records using apex and it is throwing me an error: entity is deleted List<MyObject__c> undeleteObj = [select id, Unique_Id__c from MyObject__c where ...
1
vote
2answers
55 views

Binding variables in dynamic soql

I am trying to dyanically attach a WHERE clause to a base query string by following this guide. https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dynamic_soql.htm I am ...
1
vote
0answers
33 views

Get the number of Opportunities for each User in the org (the count must include the records to which the User has atleast read access)

I need to get the count of Opportunity record for every User in the org where the User has atleast read access on the Opportunity record. I need to store the data obtained per User for every month in ...
4
votes
1answer
107 views

Dynamically using Field

I have a function as below: public PageReference resendEmails() { List<ts2__Placement__c> selectedPlacements = new List<ts2__Placement__c>(); List<Timecards__c> timecards = new ...
4
votes
2answers
53 views

Semi Join on String

I have a junction object called Trip_meeting__c to connect Event to Business_trips__c. Because you can't create a lookup to Event, I am using a text field Meeting__c to hold the Event Id and will ...
1
vote
1answer
57 views

create a map with keys = fields names and values = query result

I am trying to create a map from a result of a SOQL query, this map contains the name of the fields as keys and the values of the query as values for example: List accounts = [SELECT Name, Email ...
1
vote
1answer
64 views

Using multiple variable with same name in dynamic SOQL

Good day everyone I have some problem in regards with using dynamic query with too many variables. To explain further below is some part of my code. String QueryString = ''; List<List<String>...
0
votes
2answers
59 views

How to get the records using dynamic soql for the date field which is equal to NULL

I have a requirement where the user should be able to include the records where the due date is not populated when i uncheck the checkbox field in the vf page.In my case that date field is named as ...
0
votes
1answer
83 views

How to get the records for null value in the picklist field using dynamic soql

I have a picklist field Executed__c with None,Yes,No values in it.The query which i have written is fetching the records when the user selects yes or No.But when user selects None,null value is ...
3
votes
2answers
100 views

Query non existing custom object

I'm on a developer org on which I have a managed package that I manually install on customers orgs. Each customer's org is a bit different, with different requests/requirements. The code is as ...
0
votes
1answer
41 views

SOQL not working

I have a dynamic SOQL query where in I am using order by clause.I want to sort it by product Style SOQL soql = 'select id, name,Warehouse__c,Product_Reference__r.gii__ProductStyle__r.name, ...
0
votes
2answers
48 views

Dynamic SOQL error

I am getting the following error while running my dynamic query.But when i make it normal query it works.Error is : Didn't understand relationship 'gii__Product__r' in field path. If you are ...
1
vote
1answer
36 views

Call dynamic SOQL from other method in apex

Good Day everyone, I have a problem in regards with calling a method that contain a dynamic SOQL. To explain further, below is a sample code: public class commonFunction { public static String ...
1
vote
1answer
32 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
53 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
27 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 object....
0
votes
1answer
144 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
695 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
135 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 ...
3
votes
1answer
376 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: System....
1
vote
1answer
77 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
131 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 this)....
3
votes
1answer
118 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
257 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 = \'' + String....
6
votes
2answers
474 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
46 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 ...
4
votes
3answers
157 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> ...
3
votes
1answer
470 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 List<...