Questions tagged [dynamic-soql]

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

50 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
9
votes
0answers
230 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 ...
3
votes
1answer
1k 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 ...
2
votes
0answers
524 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 &...
1
vote
0answers
66 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 ...
1
vote
2answers
632 views

Fetching Parent field value with dynamic SOQL

I am performing a dynamic query on case feed and fetching few fields including CaseNumber. queryResult is storing the results but it does not contain casenumber. I am able to retrieve caseNumber with ...
1
vote
0answers
93 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,...
1
vote
0answers
37 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 ...
1
vote
0answers
956 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. ...
1
vote
0answers
146 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,...
1
vote
0answers
62 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 ...
1
vote
2answers
474 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
vote
1answer
95 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\') &...
1
vote
0answers
275 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 ...
1
vote
0answers
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 ...
1
vote
1answer
1k 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 ...
0
votes
0answers
19 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 ...
0
votes
1answer
30 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 ...
0
votes
0answers
24 views

Is there any possibility to get dynamically child relationship names based on dynamic query/record?

Is there any way to get dynamically child relationship names from the dynamic query or even from the record(records)? Here is an example: String soql = `SELECT id, Custom_Field_1a__c, ...
0
votes
0answers
36 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 ...
0
votes
0answers
23 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 ...
0
votes
0answers
41 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 ...
0
votes
0answers
315 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 ...
0
votes
0answers
49 views

Transforming a read-only map<String,Object> criteria of a RemoteObjectController.retrieve into workable Apex SOQL?

How can a visualforce page (or the page's controller) access the NON-paginated results size of a Remote Object Model's RemoteController.retrieve query? Here is the relevant part of my override method,...
0
votes
1answer
30 views

SOQL to Pull LastLoginDate from past 2 hours but not last 30 minutes

Here is the scenario that I'm running in to. I need to able to pull users that logged in past 2 hours but not last 30 Minutes. I tried every possible way to filter this in but since we can't Use ...
0
votes
1answer
34 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()....
0
votes
1answer
42 views

Test data not visible by Dynamic SOQL

I have an seemingly simple aura enabled class for agreement lookup which returns maximum 8 records using dynamic SOQL. This class works fine from UI perspective. No issues so far while testing. My ...
0
votes
1answer
465 views

Unable to pass object Name in the SObject for loop to call methods Dynamically

I am trying to optimize my code, instead of using object Name in if else I want to pass the SObject parameter and combine below code Instead of using separate objects I am trying to merge if else ...
0
votes
1answer
108 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 ...
0
votes
0answers
457 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
1answer
123 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 ...
0
votes
0answers
269 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. ...
0
votes
1answer
203 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 ...
0
votes
1answer
137 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 ...
0
votes
0answers
38 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 ...
0
votes
1answer
285 views

Dynamic select KnowledgeArticleVersion by Language

I have the following code: List<KnowledgeArticleVersion> articles = [SELECT Title, UrlName, FirstPublishedDate, Summary, ArticleType, LastModifiedDate FROM ...
0
votes
1answer
85 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 ...
0
votes
1answer
358 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
110 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
1answer
355 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 ...
0
votes
1answer
250 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 ...
0
votes
0answers
115 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 ...
0
votes
0answers
287 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,...
0
votes
0answers
223 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 ...
0
votes
0answers
170 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 ...
-1
votes
2answers
39 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 ...
-1
votes
1answer
704 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....
-1
votes
1answer
107 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 ...
-1
votes
1answer
307 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
1answer
142 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 ...
-3
votes
1answer
92 views

how to use like in where clause of SOQL for string

for below query like is not working static final String OrgUrl=system.URL.getSalesforceBaseUrl().toExternalForm(); string sl=[select Identity_Provider__c from Org_Url__mdt where label like:'%'+...