Questions tagged [dynamic-soql]

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

41 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
9
votes
0answers
95 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
652 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
399 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 &...
2
votes
1answer
408 views

Select names of multiple sObject types in one query

I have a set of record id and I don`t know types of this records. Can I select only field name for this record ids in one query? I thought something like that: List<ProcessInstanceWorkItem> ...
1
vote
0answers
27 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
182 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
1answer
277 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
0answers
116 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
43 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
1answer
309 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
94 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
270 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
40 views

How to Query Knowledge Article based on Data category and Topics in Salesforce?

I have a Knowledge Article Type = AT1 and Data Category = DC1, DC2 and DC3 and Topics T1 and T2. I am trying to retrive Knowledge Article Version in apex class which contains Article Type AT1 and Data ...
0
votes
0answers
85 views

How to build the dynamic search query for multiple conditions in lightning

Hi can anyone help on this, My requirement after users selection of field, operator and value on each row on click of button it will able to call a dynamic search query with all these selected fields,...
0
votes
0answers
27 views

Unable to retrieve records from the dynamic sObject list

I have written some dynamic code for selected object listview. I want to show all recods which belong to the dynamic sObject but I am getting this error ( Invalid field Title for Contact ) for every ...
0
votes
0answers
19 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 ...
0
votes
0answers
159 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
67 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
85 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
163 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
62 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
2answers
455 views

How to combine the two soql queries as a single SOQL query?

how to combine the two soql queries as asingle query? Contact con = [Select Id,Name,AccountId From Contact Where ContactId In (Select ContactId From User Where Id=:UserInfo.getUserId()]; List<...
0
votes
0answers
37 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
259 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
48 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
165 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
94 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
323 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
142 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
108 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
219 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
210 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
35 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
430 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
90 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
181 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
137 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
34 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:'%'+...