Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [dynamic-soql]

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

0
votes
1answer
40 views

Can someone provide me the list of SOQL exceptions?

Can someone provide me the list of SOQL exceptions? a URL link which has all the exceptions and explanations. Thanks in advance
-1
votes
1answer
32 views

Error: Compile Error: Found punctuation symbol or operator '%' that isn't valid in Apex. at line 14 column 362

global class ABI_SFA_TAC_Removal_Batch implements Database.batchable<sObject> { // variable decleration. public String Query; /* Method Name: Start Description: This ...
1
vote
1answer
40 views

Forming a dynamic SOQL with multiple fields in WHERE clause

I have written a method to dynamically query an object and its fields. As I want to keep it configurable, a fieldset is used to provide with which fields to query, and also the object. The problem I ...
3
votes
1answer
33 views

Is Contact othergeocodeaccuracy a legitimate field?

Many of our Continuous Integration builds just failed with hundreds of this error: System.QueryException: No such column 'othergeocodeaccuracy' on entity 'Contact'. Our code does describe calls ...
2
votes
1answer
55 views

Is it possible to rebind for dynamic SOQL in a more scalable way?

I came to the realisation that it isn't difficult to create my own String Interpolation, like this: public class XAP_UTIL_MapInterpolation implements XAP_UTIL_InterpolationIntf { String template; ...
0
votes
2answers
173 views

System.QueryException: unexpected token: '<EOF>'

I have built dynamic query.but receiving below exception 01:16:56.0 (15683245)|USER_DEBUG|[335]|DEBUG|SetOfParentId--->{} 01:16:56.0 (15756602)|USER_DEBUG|[336]|DEBUG|Set1--->{} 01:16:56.0 ...
0
votes
0answers
15 views

get records based on recordtypeID and listviewID

I need to get records based on recordtypeid and listviewid but it is returning all records. I don't know where I'm doing it wrong.(it will return records based on listview but recordtypeid condition ...
1
vote
1answer
141 views

System.QueryException unexpected token

Trying to return all fields in object System.QueryException: unexpected token: '(' when I run the Invocable class at the parents = assignment public with sharing class AuditReportBulkifyClass { ...
1
vote
2answers
27 views

Query parsing error like clause

What is the correct syntax for a query that retrieves all Accounts that have __Civil_ in the Name? SELECT Id FROM Account WHERE (Name LIKE '%_Civil_%')
1
vote
1answer
48 views

How to find SOQL syntax error?

I have an error somewhere in my SOQL string but can't figure out where because the only message I'm getting is 'Unknown error parsing query' if I try to execute it in the Query Editor of the dev ...
-4
votes
3answers
72 views

how to create dynamic query [closed]

List<Opportunity> opps = [ SELECT Id ,Name ,Amount ,CloseDate ,Stagename ,Near_to_Close_Date__c ...
0
votes
1answer
47 views

Need Help on Modifying Code [closed]

I found this example on a dynamic hierarchy for Accounts and I need help as to how to modify it to display an account hierarchy. I am unable to figure out why I recieve this error message when testing ...
0
votes
2answers
51 views

Trying to access unique records and the records of those unique records from the same table

select Id, Name from sumchans__AddressReportMATeam__c where Name in (select Name from sumchans__AddressReportMATeam__c group by Name LIMIT 3) I am not sure how to explain what I am trying to get here....
1
vote
2answers
133 views

Error encountered with usage of != or <> operating for SOQL query in batch class

I get the following error in Developer Console (logs) while executing this batch class with the following code snippet. 20:07:09:029 FATAL_ERROR System.QueryException: expecting a colon, found '(' ...
0
votes
1answer
24 views

Construct Sforce.connection.query

I have a query for a JS button: ccid = sforce.connection.query("Select Id, Account__c from CCI__C Where IsActive__c = True AND Account__c ='" +AccountId+ "'"); It is working fine. Now I want to add ...
0
votes
0answers
65 views

Database.query is not returning data

I have a problem with the Database.query. Its not returning the data to the Apex class, But when I am using the query editor, its showing the correct data. My query is List<CM_Group__c> e = ...
0
votes
2answers
97 views

Dynamic Batch apex with sobject iteration

I have a batch apex which takes the record from source object (can vary like Opportunity, Opportunity line item etc) and paste the record into target object i.e Opportunity_Prod_Batch_Record__c (fixed)...
0
votes
1answer
113 views

How to get the Data Category in Select Dynamic Soql

I am trying to fetch Knowledge Articles based on Data Category through the below dynamic Soql query. String dynamicQuery = 'SELECT Id, Title FROM Knowledge__kav ' + ...
0
votes
1answer
39 views

How to query parent record picklist field value in dynamic WHERE clause

I want to develop a WHERE clause for a dynamic SOQL query in a utility class. The WHERE clause should lookup a parent record picklist field value.The relationship between Shared_Contact__c and Contact ...
0
votes
2answers
31 views

SOQL query to identify Account names with out any number

I require to grab all account names which does not contain any number and display in the report. I am trying to query it using LIKE, but it is not working. My query - [select name from account where ...
0
votes
1answer
11 views

Trouble with lookup relationship parent query

I'm trying to construct a query that takes a specific Contract with a provided Id, and I want to fetch from this record, the related Order's, and their OrderItem's, So If I understand correctly I ...
-1
votes
2answers
54 views

Unexpected Token Where

for(AggregateResult hier:hierarchy) { fld1.add((String)hier.get(Field1)); fld2.add((String)hier.get(Field2)); fld3.add((String)hier.get(Field3)); } string Soqlstr2='...
-1
votes
1answer
27 views

Multiple group by problem [closed]

I need to find the name of the common records which have similar fields in them. For Example - I will create a vf page to dynamically take 3 fields for an object. And I need an Soql Query to search ...
0
votes
2answers
227 views

how to write Dynamic SOQL query using Not equal operator

MALFORMED_QUERY: Opportunity__r.LeadSource != 'Website'); ^ ERROR at Row:3:Column:89 unexpected token: ; SELECT Id, OwnerId, WhatId,Reminder_Date_Time__c, WhoId,Record_Type_Name__c, ...
3
votes
1answer
99 views

Select aggregate into Integer using Database.query()

So we all know we can put an aggregate directly into an Integer, like this: Integer countAccounts = [SELECT COUNT() FROM Account]; Is it possible to do the same thing, using Database.query()? ...
6
votes
3answers
294 views

Select into Map using Database.query()

So we all know it is possible to directly select into a Map, like this: Map<Id, Account> accounts = new Map<Id, Account>([SELECT Id, Name FROM Account]); Is it possible to do the same ...
-1
votes
1answer
22 views

Need to get schema field of a object while process [closed]

I tried as below mentioned code, for adding field value in dynamic way String type='Object__c'; Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe(); //getting required custom ...
1
vote
0answers
72 views

Bulkify dynamic query Batch Class?

I converted existing batch class that was processing single record into schedule/batch class that can process multiple records. But I got stuck in bulkifying the dynamic SOQL inside the for loop. ...
0
votes
1answer
151 views

How to check if sObject/sObectType is supported in SOQL?

I'm working on a SOQL query builder which should show all the Objects of an Org which are supported in SOQL query. I've used Schema.getGlobalDescribe() to get all objects name. Though it returns all ...
-1
votes
1answer
116 views

Picklist related Query in salesforce

I Have a Picklist Field Like (Orderstatus__c) Field, Values are (A, B, C, D, E, F) This Picklist Field, when i am querying the Orderstatus__c Filed Those values will be displaying like Un order (B, E, ...
2
votes
2answers
90 views

SOQL search with LIKE

I’m very confused with the soql Like operator. If I have a record with a text field that may contain: "Orders to be shipped, pack blue labels/zip/ authorization slip needed.” And a user enters “blue ...
0
votes
1answer
25 views

Bulkify Apex class for event object using dynamic soql

I'm trying to get the name of whatId and WhoId on the event object onto a string. I can do it for a single record inside a for loop, the issue I see when Im looking to bulkify the code is that events ...
0
votes
1answer
31 views

SOQL is bringing users who are not visible to me

I have implemented a searchable drop-down using jquery and visual force. Whenever I start typing a string it will search the database and bring all the matched users. I am using a jquery to call a ...
0
votes
1answer
43 views

Generate Dynamic Query without Nested Loop

The requirement is to store object name and field name in the custom object so user can defined object and condition to display survey question. I am developing skeleton code to support the ...
-2
votes
1answer
232 views

How to bind list of string in dynamic SOQL

List<String> cityList = Label.cityNames.split(','); String SOQL = 'Select id, name from Account where city IN:cityList' Databse.executeQuery(SOQL); Could you please correct the above ...
0
votes
1answer
27 views

How to get Two articles in One list using salesforce query

Hi every one I have a two articles: Offer__kav and Offer_order__kav. How to Query This Two Objects Related All Fields. For Ex: I tried : List<List<SObject>> search_results = [FIND 'SFDC'...
1
vote
1answer
321 views

How to query the KnowledgeArticleVersion and Linked Article Objects in sfdc

i get "SELECT id, abdulking__Knowledge_Linked_Artical__c ^ ERROR at Row:1:Column:12 No such column 'abdulking__Knowledge_Linked_Artical__c' on entity 'KnowledgeArticleVersion'. If you are ...
0
votes
3answers
316 views

Convert string to query

Can anyone help me on how to convert the String q1 into a query? I am trying to put my variable 'q1' inside the [] but I always got an error "Unexpected token q1" Heres the code. String q1 = 'SELECT ...
2
votes
1answer
405 views

Combine multiple SOQL queries on multiple objects into one

Background & Data structure: please click here to data structure image Each contact can have multiple tours/trips and each trip will have records in 3 custom objects (with a lookup ...
0
votes
1answer
43 views

SOQL Parent Child Query Salesforce

I am new to salesforce, I am using the below query to fetch data from Salesforce Approval Process, Here actorId is the Id which matches with the Id of User table. I need User email from the User table ...
4
votes
2answers
470 views

Iterate over a dynamically populated list of objects

I have a SOQL query where I don't know the FROM object, meaning it can change every time. So I dynamically populate it like so // dynamicObject is a String. String queryString = 'SELECT ' ...
0
votes
1answer
20 views

Getting some kind of ID when querieng the field in soql [duplicate]

For below query: System.debug([SELECT ContactMobile FROM Case]); I'm getting: 15:13:52:137 USER_DEBUG [1]|DEBUG|(Case:{Id=5003C000001YKoSQAW}, Case:{Id=5003C000001YKoNQAW}, Case:{Id=...
1
vote
1answer
175 views

Soql giving id for field when qurieng lookup field

For below query: System.debug([SELECT Id, Account_lookup__r.Account_Number__c FROM Case]); I'm getting: 12:05:52:125 USER_DEBUG [1]|DEBUG|(Case:{Id=5003C000001YKoSQAW}, Case:{Id=...
1
vote
2answers
195 views

Getting SF report information using SOQL

I have a SF report created in the Salesforce of type 'Contacts With Opportunities'. I need to set the ETL automation for this report using python.: Please have a look at following screenshot: I have ...
1
vote
3answers
526 views

Like Operator is not working with Dynamic Variable in SOQL Query

Here I'm trying to perform LIKE operation in SOQL when I'm passing a variable dynamically the Query is not returning the results? List<string> companies=new list<string>(); List<...
0
votes
1answer
41 views

Search for related records?

I have a context aware (hasRecordId) Lightning component that can be dropped on an undetermined custom object record page. I need the component to grab the recordId, then search for that recordId ...
1
vote
0answers
89 views

Dynamic Soql On multiple objects

I want to search on multiple objects using dynamic soql, below is the query where iam want to search any record from any object using dynamic soql. select id,StageName,name, (select id,ProductCode,...
4
votes
2answers
128 views

Can Apex SOQL query variable binding be done in a method other than the method which invokes Database.query?

Apex Commons has some brilliant solutions, but one of the things which I feel is missing is an object-oriented approach to the SOQL query's "WHERE" conditions. I'm presently working on my own ...
1
vote
0answers
95 views

What deep magic exists in Apex and can we replicate it? [closed]

When reading Apex code, there are at least two instances where SFDC is doing something more than the is immediately apparent given the syntax of the code, both of which somehow relate to SOQL: SOQL-...
0
votes
1answer
65 views

Display dynamic calculated field names in Visual Force page [closed]

I have an object as objDates with field names as Day1__c, Day2__c and so on till Day366__c. I'm using DayOfYear() to access the field values dynamically. I'm able to read(get) and write (put) values ...