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

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

-1
votes
1answer
21 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
47 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
21 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
26 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
56 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
26 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
56 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
229 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
72 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
29 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
177 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
26 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
45 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
157 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
23 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
40 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
85 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
90 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
57 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
33 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
36 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
86 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
202 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
56 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
186 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
43 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
71 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
80 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
294 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
86 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
434 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
93 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
103 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
152 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.
2
votes
1answer
236 views

Database.Query Variable Does Not Exist

How can I get the field results from a dynamic database query to be available to be put into a list? Here is the code I have: //Query on the destinationObjectFieldName results List<sObject> ...
1
vote
0answers
36 views

Fetch records from child relationship using Apex [duplicate]

I have a remote action that need to fetch an object child relationship data, but the catch is that is has to be dynamic. For example, the remote action will get Case, CaseComments, list of fields in ...
0
votes
3answers
523 views

how to pass picklist value in Dynamic SOQL

I am using dynamic soql where I am reading the conditions from an XML and getting those as a String but I am not able to find it who the query will structure String query = 'SELECT id, Name FROM ...
1
vote
1answer
49 views

Dynamic soql reference JigsawCompanyId field

In dynamic Soql  when I try to query JigsawCompanyId , it queries null.name for ParentID I queried parent.name, like wise for JigsawCompanyId how should i query SELECT Name,AccountNumber,ParentId,...
2
votes
2answers
251 views

Dynamic soql query passing null ID value

Using a dynamic soql query in my managed package , In my where condition am passing id value, string whereCond = NameSpace('fldName') +' = \'' +keyType+ '\'' +' and ' + NameSpace('fldName') +' = \'' +...
0
votes
0answers
446 views

How to use “onChange ” on lightning components? [duplicate]

I'm working on salesforce communities and here i'm trying to achieveing is once the community user login it displays a dropdown button with community user accounts,here by selecting the one ...
0
votes
0answers
336 views

By selecting a value from Lightning dropdown doesn't display anything

I'm working on salesforce communities and here i'm trying to achieveing is once the community user login it displays a dropdown button with community user accounts,here by selecting the one ...
0
votes
1answer
47 views

How to display all accounts once the contact login as Community user?

From the below code i can get the all Accounts linked to that contact(community user).but here the problem is i'm using the email id as static how can i make this dynamic.once the community user login ...
1
vote
2answers
613 views

Custom Metadata type variable for SOQL In Clause

I query a custom metadata type value and try to use it in IN clause. Scenario 1: Works! Custom Metadata value has AccountHandlerTest ( not in single quotes). ACustomMetaDatatype__mdt custMeta =[...
0
votes
1answer
52 views

SOQL equivalent of PATINDEX()

Trying hard to find an equivalent for the below SQL. Any help/suggestion PATINDEX('%[0-9,c][0-9,p,a][][A-Z,0-9][A-Z,0-9][A-Z,0-9][][1-9,A-Z][0-9,A-Z][0-9][0-9][0-9]%', FIELDNAME) > 0
2
votes
2answers
297 views

Workaround for SELECT * (SELECT all) in sfdx force:data:tree:export SOQL

In certain parts of our existing Apex code base, we've used dynamic soql in combination with object describe methods as a workaround to achieve the equivalent of SELECT * that's normally available in ...