Skip to main content
New
Stack Overflow Jobs powered by Indeed: A job site that puts thousands of tech jobs at your fingertips (U.S. only). Search jobs

Questions tagged [dynamic-soql]

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

51 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
9 votes
0 answers
349 views

Is there a work around to allow binding of variables in the sfdx force:data:tree:export query file

When using sfdx force:data:tree export with an in-line query, you can bind variables by creating them in the cli before running the export command, like so: CURRENTYR=2017 sfdx force:data:tree:export ...
KB145's user avatar
  • 876
3 votes
2 answers
2k 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 ...
SK25's user avatar
  • 31
2 votes
0 answers
614 views

How to dynamically query in Remote Object Model?

See my code comments in my controller for what I'm trying to do. This article might help as well: Overriding Default Remote Objects Operations Page <apex:page> <apex:remoteObjects &...
Peter Noges's user avatar
  • 1,130
1 vote
0 answers
32 views

Can't figure out why list aura component won't display the account name

It's meant to pull the recordId from the url of a users record page and use it to display a list of that users open opportunities. Everything is working without a hitch, except the account names aren'...
SethH's user avatar
  • 41
1 vote
0 answers
573 views

Is that possible to use query plan for dynamic SOQL queries?

I know we can verify straightforward SOQL in query plan. Now, I am trying to find a way to use query planner for a dynamic SOQL queries. My SOQL query depends on several Ids (list of Ids) and binding ...
Bforce's user avatar
  • 6,828
1 vote
0 answers
435 views

ContentDocumentLink Limitations when querying using LinkEntityId as filter

my apologies if this has been asked somewhere else. I didn't find any answer hence I have to post this question. USE CASE: I am using database.query(queryString); In queryString = 'SELECT id,...
Anvesh Singh's user avatar
1 vote
0 answers
92 views

getDescribe Failing on Individual Object Id in Tests (Data Protection and Privacy)

My tests of methods using dynamic SOQL queries stopped working after enabling Data Protection and Privacy. I receive the following Exception: FATAL_ERROR caused by: System.SObjectException: Field ...
Cleverlemming's user avatar
1 vote
0 answers
1k 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. ...
Serena's user avatar
  • 33
1 vote
0 answers
191 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,...
Nagaraju's user avatar
1 vote
0 answers
138 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 ...
ASHWATI KRISHNAN's user avatar
1 vote
2 answers
1k 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
nirp's user avatar
  • 19
1 vote
1 answer
98 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\') &...
human's user avatar
  • 655
1 vote
0 answers
287 views

Nested Query error

I have below nested query where Line Item is child of Inc Transaction and all field names are valid still I am getting errored out Can someone please help me here? NESTED QUERY: select ...
Testing_SFDC's user avatar
  • 2,940
1 vote
0 answers
2k views

Trying to determine fields I want to set dynamically rather than hardcode - very close / not possible

I am messing around with the dynamic nature of Salesforce. I want to clone Opportunity into a custom object. It's a very easy requirement in itself. What I am trying to do is make if completely ...
Michael Gill's user avatar
  • 2,202
1 vote
1 answer
2k views

Sorting functionality using dynamic soql

I have created a visual force page in Account page that displays related opportunities by RecordType(5 Records at a time) for the given Account and when click on Go to List it directs to new VF page ...
naga42's user avatar
  • 21
0 votes
2 answers
69 views

I am trying to fetch Account details with the text provided in lightning input lwc

I am trying to fetch the Account Name and Id while entering the text on ligtning input but I am not able to fetch the data from apex here is my code.Pleas help <!-- mySearchListDemo.html --> <...
Puja's user avatar
  • 13
0 votes
0 answers
48 views

How to modify and run SOQL query dynamically in swift/Objective-C SalesforceSDK 10.2.0?

How Update with dynamic value in the Where clause from Swift/Objective-c coding in the below 'usersyncs.json' configuration. ''' { "syncName": "syncDownUser", "syncType": ...
adijazz91's user avatar
  • 101
0 votes
0 answers
522 views

SOQL problem with redundant white space

My record has an 'Adress' string field and the value like this: 'SNBR - 772178 SNME SSTTAB, SCITY SSTATE SZIP_' Note that it has 2 whitespaces between 'SSTATE' and 'SZIP_'. However, this field when ...
Tuấn Trần quốc's user avatar
0 votes
0 answers
188 views

Implementing autocomplete suggestion for record ids

The LWC app that I am currently working on has a feature that lets users fetch information for a record whose record ID is entered. I am looking forward to implementing a feature that proactively ...
darthcoderUS's user avatar
0 votes
0 answers
2k views

How to get all the field names and data type of each field using Dynamic SOQL with Lookups?

I am trying to get the Datatype, Label, and SObject of fields in a Dynamic SOQL Query. For Example, I have the following objects that are called in the below SOQL Query: "Product_User__c" &...
Matthew Metros's user avatar
0 votes
0 answers
21 views

Test works from Dev Console. Fails in automated nightly run

My query was failing with users with a Locale other than "en_US". So I switched the date format from UTC to GMT and it works well. Unfortunately while my tests work when I run them from Dev ...
afandre's user avatar
  • 71
0 votes
1 answer
1k views

How to query only the labels for custom or standard objects

SELECT Fields(standard) FROM Contact This queries all the records of all the fields in the Contact object, but I want to query only the labels of the fields so that I can create a picklist of all the ...
Zan3's user avatar
  • 39
0 votes
0 answers
424 views

Valid SOQL that returns results does not return when run dynamically

I have an Apex class that runs a dynamic SOQL query. The logs say "Aggregations:0". However, when I copy/paste the executed query directly from the log into developer console, it returns ...
Josh's user avatar
  • 11
0 votes
0 answers
101 views

Trying to query a limit of 100 orders that are broken up into multiple records based on the item

I need some assistance with creating a query that will get all the records that correspond to the first 100 orders. For example the table looks something like this: I know I can use GROUP BY grab the ...
Jebert's user avatar
  • 15
0 votes
0 answers
167 views

Create a dynamic query for each item in for loop

Hi I want to create a dynamic query for each item in for loop , but again I don't want to execute that query in the for loop, right now since I am creating a query in for loop, I am no option but ...
Isha's user avatar
  • 163
0 votes
0 answers
930 views

Apex to return custom metadata and dynamic object data

I am looking to have a lightning web component that returns data from an object based on the record I am on that i can display on a lightning record page . I am exploring programmatically pulling a ...
DigitalWoman's user avatar
0 votes
1 answer
491 views

Select all fields in a custom object dynamically in a specific order

I have a custom object that I need to select all fields from in a specific order to create a text file in a specific format. So far, I've been dynamically accessing all the fields I need via .getMap()....
sFishman's user avatar
0 votes
1 answer
328 views

SOQL injection issue on source scanner report

I am getting SOQL injection vulnerability on source scanner report. Please check one of the issue below. I tried string.escapeSingleQuotes() on query string. It is helping with removing this issue in ...
AshSFcloud's user avatar
0 votes
0 answers
748 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 = ...
Salmaan C's user avatar
  • 101
0 votes
1 answer
271 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 ...
PatMcClellan__c's user avatar
0 votes
0 answers
379 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. ...
Ysr Shk's user avatar
  • 3,157
0 votes
1 answer
266 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 ...
consultantsfdc's user avatar
0 votes
1 answer
283 views

Filtering results of an SOQL query

I have a SOQL query with a lot of filters and I want to group the results and process objects which match a certain filter. For eg. I could have a query where I want to process different kind of leads ...
user1104's user avatar
0 votes
0 answers
43 views

“System.LimitException: Too many SOQL queries: 101”

I have SOQL on 17 objects to delete sharing Need help since we cant use SOSL on _share__c objects list<Lease__Share> deleteLeaseShare = new list<Lease__Share>([select id from Lease__Share ...
SFDC shaikh's user avatar
0 votes
1 answer
303 views

Dynamic select KnowledgeArticleVersion by Language

I have the following code: List<KnowledgeArticleVersion> articles = [SELECT Title, UrlName, FirstPublishedDate, Summary, ArticleType, LastModifiedDate FROM ...
JKasyan's user avatar
  • 195
0 votes
1 answer
151 views

label value inside another label

There is a label label_query which contains the SOQL query say 'Select name from Account where recordtypeId = 'value coming from another label'. In another label is stored recordtypeid. Now to use ...
s_saiyan's user avatar
  • 520
0 votes
1 answer
686 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....
Learner_sfdc's user avatar
0 votes
1 answer
121 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, ...
Samir's user avatar
  • 2,679
0 votes
1 answer
416 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 ...
user12106's user avatar
  • 225
0 votes
1 answer
658 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 ...
Rufus K.'s user avatar
  • 505
0 votes
0 answers
119 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 ...
Sharat's user avatar
  • 1,029
0 votes
0 answers
430 views

Error as MALFORMED Query in Developer console (Group by Rollup, Group by Cube)

Why do I get this ERROR as :MALFORMED Query in Developer console? I'm trying to use :Group By Roll or Group By CUbe to get the subtotals and grand totals. When I tried this Query: SELECT id,...
nikkey's user avatar
  • 1,365
0 votes
0 answers
226 views

Visualforce Error - Dynamic SOQL Binding

I have queried Account record using dynamic SOQL <apex:PageBlockTable id="tableid" value="{!lstAccount}" var="acc"> <apex:repeat value="{!lstField}" var="f"> <apex:column ...
Salesforce Steps's user avatar
0 votes
0 answers
174 views

Issue in wrapper class

In the following snapshot we are fetching parent and child records using wrapper class.Selected child records should be displayed in selected course.But whenever i select child records only last ...
Binu Sfdc's user avatar
-1 votes
1 answer
551 views

How can i use custom label values in Squery- of apex class

Can anyone help me to form the dynamic query with the LIMIT value stored in custom label. Public String valueForLimit = System.Label.BuyListCustomlabelLimit; How can i use the valueForLimit in ...
Kiaty's user avatar
  • 1
-1 votes
2 answers
71 views

get a record from obj A which is created after 3 minutes of another record in another object obj B

I am unable to form a SOQL query to get a record for below scenario. Get a record from obj A which is created after 3 minutes of another record in another object obj B. And also i want to get first ...
Test's user avatar
  • 1
-1 votes
1 answer
888 views

Warning when using fflib_QueryFactory

When performing a sub query, I get the following message: WARN|fflib_QueryFactory.subselectQuery(Schema.SObjectType) is deprecated and will be removed in a future release. Use fflib_QueryFactory....
ramondea's user avatar
  • 187
-1 votes
1 answer
137 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 ...
Vijay Kumar's user avatar
-1 votes
1 answer
429 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, ...
ali's user avatar
  • 13
-2 votes
1 answer
149 views

apex trigger issue with dynamic soql

custom object: schedule_c fields: Runway_C and date_C Runway_c is a picklist field having track1 and track2 values. date__c field is datetime field. i having the the records in schedule object e.g ...
user5446's user avatar