Questions tagged [soql]

Salesforce Object Query Language (SOQL), modeled on SQL, for accessing information saved in the Salesforce database.

Filter by
Sorted by
Tagged with
0
votes
1answer
43 views

How to avoid calling a method with soql inside loop?

I am writing a batch class in which I am calling my custom-defined method inside for loop. But the main problem is my custom-defined method executes a soql query which means it's a bad idea to call it ...
0
votes
1answer
46 views

How can I get the full value of a variable while debugging Apex?

I'm using VS Code with the salesforce extensions to debug a test method. A query executed by the method is returning no records when I think it should be returning one. So I click on the "Debug ...
0
votes
1answer
45 views

select object based on another related object fields

I have two object Countries and market that are related. One country has many markets but one markets has one country. Now market have a checkbox field that is focus_year that is selected if we want ...
2
votes
2answers
81 views

Update active flow via sfdx

Is it possible to change the status of an active flow to inactive via sfdx? I tried it with sfdx force:data:record:update and following query: SELECT ActiveVersionId, MasterLabel, DeveloperName from ...
2
votes
1answer
149 views

How do I create Duplicate/Matching Rules through Apex code for an Apex test class?

I recently wrote an API to implement Account/Contact Duplicate/Matching rules for a connected app. It all works fine. It does the same thing that Salesforce does for these rules. It pretty much ...
0
votes
2answers
58 views

Apex Strings : Pipe symbol (|) is converted to | in string variable while querying

I'm trying to query a field on Object__c which stores information like (1001|01). Example: String str = '\'1001|01\''; List<Object__c> recordList = [SELECT ID FROM Object__c WHERE Field__c ...
0
votes
1answer
53 views

Database.executebatch call in for loop causing Codescan warnings

I have a piece of code that is causing some codescan warnings and it is not liking the database.executebatch in the for loop. The thing is I am not sure to go around it My code: public with sharing ...
1
vote
1answer
141 views

Why does SOQL return related records when run directly but not when run with Apex?

I have a SOQL query that looks like this: SELECT Id, OwnerId, IsDeleted, AboutThirtyFieldsTotal__c, ... (SELECT Id, IsDeleted, OverFiftyFields__c, ... FROM Borrowers__r ) FROM Loan__c WHERE LSC__c = '...
-1
votes
1answer
37 views

Child to parent SOQL query inside a parent to child query

I need a query to get the Name of the records referenced in the WhatId and OwnerId fields of the ActivityHistories related to a contact. How can I go about bulding this query? This is what I have so ...
0
votes
1answer
34 views

How to fetch the latest file in SOQL from each Order record

I am querying files from the list of Order records through SOQL. I have added my SOQL query below for your reference. I want to query only the latest file which begins with 'IO_' from each Order ...
2
votes
1answer
53 views

FLS in SOQL - VisualForce vs LWC

I have a VF page and an LWC, both the UI are displaying a datatable of records Project__c. User A (Standard user) doesn't have access to Report__c and Geographic__c field on Project__c. The VF page ...
-1
votes
2answers
270 views

Method does not exist or incorrect signature: void indexOf(Group) from the type String

I have written an Apex code for whenever a new Record for City_census custom Object is inserted, the approver should automatically be the owner of that record based on their City. In Custom Metadata, ...
1
vote
1answer
34 views

How do I find all records from one master object to another?

I have two objects with a join object between them that has a master/detail relationship to each of them: Loan__c <- TagAssignment__c -> Tag__c. Given a query that gives me a set of loan records ...
-1
votes
1answer
51 views

Get data using Soql ,where week starts on Monday (not Sunday)

I'm trying to count the number of new opportunities by week where the week starts on Monday and ends on Sunday. I can get the query to work fine when the week starts on Sunday (which is the default), ...
0
votes
1answer
42 views

Check if list of users has access to list of account records

Before Creating an accountShare record I need to check first if the user has access to the related record I am well aware that I can get it done using the UserRecordAccess Object select RecordId, ...
0
votes
1answer
112 views

The same SOQL query returns different results from Apex code which was called from LWC

I need to get tab visibility for Permission Set. I have tabs for 2 objects:Account and Account__c. I use this SOQl request: SELECT Id,Name,Visibility,ParentId FROM PermissionSetTabSetting WHERE (...
0
votes
1answer
20 views

IN keyword in Salesforce REST API query

I have a list of Contact Ids in javascript and want to get the Contact records of the respective Ids from Salesforce using REST API but am not able to create the query using IN keyword as it is giving ...
0
votes
1answer
22 views

Onclick function to change SLDS vertical navbar to active

Iam working on a visualforce page with SLDS As you can see option B is highlighted as li class has slds-is-active on it. But it remains the same as it is throughout. Is there a way I can change the ...
0
votes
1answer
36 views

Trigger for New and Existing Account Cases without using query in For-Loop [closed]

Good day, I am writing a code that would check if an active case is existing or not. An if statement would figure out whether the case status is New || Working || Escalated. Then, a switch statement ...
1
vote
1answer
129 views

Can I query formula fields in SOQL?

I have a custom object with a custom formula field. When I try to query that field, I get an error. % sfdx force:data:soql:query --query "SELECT FullNamePrimary__c FROM LoanBorrower__c" ...
0
votes
2answers
31 views

Getting All Contacts per each Account via Map-List from SOQL - Field must be grouped error

Good day, I am writing this simple line of code using Map and List when fetching rows from a SOQL statement: select id, AccountId, FirstName from Contact where AccountId !=NULL Here is the code I have ...
0
votes
0answers
38 views

USING SCOPE "team" not working in SOQL

I try USING SCOPE in SQOL to return all accounts assigned to account team. I took a look at the documentation and wrote the following in an Apex Class: SELECT Name,Phone,Site,Type FROM Account USING ...
0
votes
1answer
31 views

How to create a query that returns only cases on the platform that have more than 10 years since the creation date?

How to create a query that returns only cases on the platform that have more than 10 years since the creation date? I did this query but it returns data with less than 10 years of creation. SELECT ID, ...
-5
votes
1answer
45 views

Facing Too many SOQL queries: 101 exception, anything wrong? [closed]

I am facing 101 SOQL Limit exception here, I tried to keep this out of loop, any idea why is this occurring? template = (String) mapofDataBlock.get('template'); mk2021md__mdt dataBlockTemplate = ...
-2
votes
1answer
65 views

Count the number of pages of a PDF stored as an Attachment from Apex code [duplicate]

Is there a way to get the count of pages in an Attachment? List<Attachment> attachments = [SELECT Id, Body FROM Attachment WHERE ParentId = :myRecord]; I am using this SOQL to get the Body, but ...
0
votes
1answer
20 views

How to query Salesforce using multiple emails from a csv file?

I'm trying to export data from Salesforce but only those that match the emails I have in a csv file. I'm thinking of using Dataloader but I don't know exactly how to do that. I checked the Developer ...
0
votes
1answer
33 views

Unable to access processnode fields from processinstancestep

Require to processnode field data from processinstancestep. While using query- Select StepNodeId from processinstancestep It is returning the values as expected But while using query- Select ...
-2
votes
1answer
59 views

Dynamic SOQL with multiple conditions and undefined amount of variables

I have SOQL like this: [SELECT id FROM CONTACT where lastName =:lastName AND firstName = :firstName] But what to do if there are only lastName variable? What if there are 3 variables or more? I ...
0
votes
1answer
24 views

SOQL query on One Record out of multiple records

i have handler trigger which calling a apex class, i want that when i am inserting a new contact through UI when i enter email field of new contact then the new contact's phone number must be that of ...
0
votes
2answers
29 views

Query to filter Accounts with specific products, using Opportunity LineItem

I wanted to pull in a query all of our customers that have bought an specific product,I tried to do it like this, but I got an error telling me that I cannot have more than 1 level of relationships: ...
0
votes
0answers
24 views

Issues Updating a Contact via API

I am new to SalesForce as a whole, let alone needing to use its API. We keep track of and manage Contact information in a Google sheet, so that NON-Sales reps who assist with post sales can reach out ...
0
votes
2answers
56 views

Get Id of the newly created record in Apex

I have the following Apex method: public static void createJourney(Id accountId) { // Step 1: get account record type Account accRecTypeName = [SELECT Id, RecordType....
0
votes
2answers
88 views

Soql query to check record type

I want to check the record type of Account before doing anything else. I have the following method: public static void methodName(Id accountId) { // get account record ...
0
votes
0answers
62 views

How to iterate the scopes of all of the connected apps to my account?

I was asking How should one fetch Application Permissions via API?, but apparently it wasn't so clear, so I'll try to rephrase it. What I am trying to do, is to fetch thru API the scopes of all of the ...
0
votes
0answers
23 views

Account with Event tagging of Yes or No in SOQL

My objective for this query is to show all of his/her accounts with tag of With Call Event (Yes & No). Meaning, Fields = "Branch", "With Call Event?" I tried below class but ...
0
votes
1answer
25 views

How do I export all email addresses associated with an Email Alert?

I need to generate a list (csv, Excel, etc) of all Recipients of a particular Email Alert. This alert contains Roles, Users and specific email addresses as Recipients, but I need a list of each and ...
0
votes
2answers
93 views

Apex Limit for trigger

i have a problem. I get 200,000 records and I have to perform some logic via trigger. the trigger at each insertion executes a query. Can you give me some advice on how to do this without exceeding ...
0
votes
1answer
92 views

Get list of objects shown in Object Manager

I'm looking for a way to get the list of objects that are shown in Setup->Objects and Fields->Object Manager, either via sfdx command line or SOQL. If I use: sfdx force:schema:sobject:list It ...
0
votes
1answer
26 views

alid initializer type list found for map : expected a map with the same keys and values or a valid SObject list

The code below causes the error mentioned in the title. Not sure what this means or how to fix it. Map <ID,ID> mapID = new Map<ID,ID>([SELECT ContactId, OpportunityId FROM ...
1
vote
0answers
32 views

Too many soql queries when trying to create a json packet for customers with Active orders

I'm trying to port over my code below to production but continue to get System.LimitException: Too many SOQL queries: 101. @RestResource(urlMapping='/my_endpoint') global with sharing class ...
1
vote
2answers
128 views

SOQL with standard objects relationship query help

I need to combine these 2 queries so that I get the Case Members and Case details in one result. There are no custom fields/objects. Both queries run independently but when I try the subquery/...
0
votes
0answers
22 views

How can I create API names in global picklist with 500 values in a fast way? [duplicate]

I have file like this with about 500 values: I am creating Global Value Set. Column A is for Label and column B is for API names. Both columns contains about 500 records. I know that I can create a ...
2
votes
1answer
42 views

SOQL Address Country not localized / translated

I'm querying an Account Address and want the country to be translated into the language of the requesting user. Sample query: SELECT BillingAddress FROM Account I maintained the translation of the ...
0
votes
1answer
47 views

Implement pagination on APEX REST Endpoint without using OFFSET or LastRecordID [duplicate]

I want to be able to get a set of records independent of previous calls. So without a LastRecordID. OFFSET also doesn't do the trick as it has a limit of 2000. For example: Query contains 10000 ...
0
votes
2answers
89 views

How to get the value of Custom field with SOQL

I am using SOQL to get team names from salesforce for each current project. It all returns, however the name is returned in ID format rather than the string name. This is confusing to me because when ...
0
votes
1answer
36 views

SOQL - how to get the first occurrence of a record, grouped by accounts

I have a table of assets I need to get only 1 asset from each account. Doesn't matter which asset. The end result should be: (In this scenario) What I tried: SELECT Id, accountid, MAX(CreatedDate) ...
0
votes
1answer
80 views

SOQL query to filter ApexClass based on the InstalledPackage

I am working on a task to retrieve test classes filtered on the basis of package that they are part of. I am trying to run the below query to do so but gets error when trying to filter on the basis of ...
0
votes
2answers
54 views

My query is returning one record, but without any data in it

I have this query to get the related data and update it, if it exists. In interface im not seeing any data, but sfdc somehow is fetching one row without any values in it.
-2
votes
1answer
27 views

Code Coverage wont Push Tru After IF

I was trying to create a unit test for my APEX Class. But i was wondering the Test wont push thru after IF statement but i was using an existing leads (046933) for testing.
1
vote
1answer
28 views

Filter records by categories SOQL

I am trying to build a query, that will return books with all information including genres of that book. I have 3 objects: Book__c in which I have all information about books, Genre__c in which I have ...