Stack Exchange Network

Stack Exchange network consists of 174 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
2answers
24 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
10 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
27 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
21 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
35 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
89 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
228 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 ...
0
votes
0answers
29 views

Pass dynamic query from Static List method with parameter to another static List method

i'm using 2 lightning components(Table component and picklist component). first i'm fetching values from picklist and sending to apex controller in below method: @AuraEnabled public static List<...
-1
votes
1answer
17 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
47 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
35 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
28 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
60 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
22 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
30 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
0answers
32 views

Picklist value is passing null value to controller class

Here is my controller class code: public String pSortedBy { get; set; } Public List<SelectOption> getSortOptions() { List<SelectOption> SortOptions = new List<SelectOption>(...
0
votes
1answer
28 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
77 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
92 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
232 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
124 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
34 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 ...
3
votes
2answers
220 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
19 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
44 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
57 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
249 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
24 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
58 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
95 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
91 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
58 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 ...
0
votes
0answers
36 views

Get nested relationships dynamically in Apex

I am building a dynamic SOQL from a JSON file. As of now, I am able to build SOQL for direct parent and direct child objects dynamically. However, I am stuck at a complex/deep relationship. E.g. ...
-2
votes
1answer
38 views

Assign row values from one object to another object as columns or fields

I have row values as dates in one object, i.e dates within a given year. I have a second object with field names as Day1__c, Day2__c and so on till Day366__c. I want to assign the dates to the fields ...
0
votes
1answer
104 views

AccountContactRelation SOQL returning null with dynamic filter values

I am trying to fetch AccountContactRelation recordsrelated to specific accountId from Lightning component via server side call. I am passing the AccountId as a param to the apex controller. But ...
1
vote
1answer
243 views

Dynamic Field References in Lightning Component

I recently posted a question regarding a component I am building. That post has the code I will be referencing. I have been able to make the necessary edits and now I return an sObject to the ...
0
votes
3answers
62 views

How to print dynamic SOQL at run time?

I have a collection of set and and i am doing dynamic binding at run time. Set<String> accountset=new Set<String>{'a','b'}; I am executing query like List< account>=[select ...
2
votes
1answer
229 views

Is LIKE Against a List Not Supported in Dynamic SOQL?

I'm trying to use LIKE in my dynamic SOQL with a list. My code: SELECT Id, Name FROM Account WHERE Name LIKE ('%somevalue%', '%testvalue%') I can't and I don't want to use variable reference for ...
0
votes
2answers
53 views

Using Apex, how can we can we query all the fields and CreatedDate for Account or any other Standard Object?

I need to run the below query for 200 fields changing the field each time and then copy the resulting most recent date.Is there any way to do this quicker than doing it 1 by 1? SELECT name, ...
0
votes
2answers
91 views

Is there a way to make dynamic apex field references bind a reference to the fields?

Is there a way to make dynamic apex field references bind a reference to the fields? To illustrate the question, let's take the following example query: String query = "SELECT myField__c FROM Account"...
2
votes
1answer
84 views

Invalid bind expression type of ANY for column of type Decimal

I know this question has been answered in few places my scenario is a bit different I think. I'm building a dynamic SOQL query, the WHERE clause is going to be dynamic. I have a List<String> ...
3
votes
1answer
360 views

Using single quote by curly braces in String.format in Dynamic SOQL

I'm struggling to use String.format to replace a token with a value when the token is within single quotes: Example: String query = String.format('SELECT Id FROM Availability WHERE Person__c = \'{0}\...
1
vote
1answer
16 views

Scheduler Class error

I am writing a Scheduler Class to send out mass Emails(HTML email template) based on the time I schedule, below is my code global class pS implements Database.batchable<sObject> , Database....
0
votes
2answers
102 views

APEX SOQL retrieve values dynamically based on string variable

In my apex code i have a variable resultField and a List<Id> objIds. What i need is a List<My_Obj__c> objs = [select Id, :resultField from My_Obj__c where Id in :objIds];. This is not ...
10
votes
1answer
457 views

Does the `getSObjects` method on `SObject` work with Person Account child relationships?

Our app uses a lot of dynamic SOQL, and in a client org I'm currently getting an error which I can't explain when we're performing a large query against account, including subqueries for all related ...
1
vote
1answer
102 views

Invalid bind expression type of String for column of type Decimal. Auto type casting?

I ran into this exception while trying to make some dynamic SOQL queries(also SOSL but haven't gotten to test those yet). Basically I'm trying to build a query string and add a dynamic value as one ...
0
votes
1answer
121 views

Dynamic SOQL Query Exception: : unexpected token: '&lt;EOF&gt;'

I am receiving the following error when running a test on my code. However, it seems to run fine in the debug line above it, so I'm confused regarding the source of the error: System.QueryException:...
0
votes
1answer
184 views

Dynamic soql picklist binding in WHERE clause

I have an auraenabled method in my lightning controller apex class. My requirement is that when user selects a picklist value of status__c and/or mode_of_travel__c as a filter and click on apply then ...
0
votes
2answers
23 views

I have 1M records -some records are from data loader and there is no picklist restriction

I have 1M records -some records are from data loader and there is no picklist restriction I want to see uniuqe values for account object with that perticular values.