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
0answers
13 views

Rest Service - Return grandchild in the response

I need to create a Rest Api where I want to take as input an Id and perform a query on an object. The response must contain the fields of this record and also some related records (children) and the ...
0
votes
0answers
19 views

Query and retrieve the fields File Object

We are currently in the process of migrating to the lightning interface and starting to use the Files instead of the Attachments. We have few Apex Classes where we query the Attachments, we want that ...
0
votes
0answers
12 views

SOQL query to get files names related to account [duplicate]

I want to get the names of all related files in the Account object. Below is my query: SELECT Name, (SELECT Id from Attachments) FROM Account WHERE Id= '0014K00000C6b7pQAB' When I run the query, it ...
0
votes
1answer
24 views

Query Accounts: How to query names and ages only [closed]

I am trying to query accounts, but it gives me errors all the time. What is the best way for querying if I only need the names and ages. And what is the way of checking how many accounts I have, using ...
-1
votes
1answer
37 views

How to bulkify my code in a better way?

I’m learning on how to code in Apex, and I’m trying to figure out how I can bulkify my code in a better way so that I won’t get SOQLExceptions. Scenario: Whenever I upload a lot of records using data ...
0
votes
2answers
33 views

EXCEPTION_THROWN [17]|System.LimitException: Too many DML statements: 1

From some research, I've seen many previous examples having the update inside a for loop which would reach over 150 DML statements if there were. I'm wondering why I still get the issue that there are ...
0
votes
2answers
19 views

Can't retrieve information from sObject

I am new to Apex so kindly help { public static void showAccountsName() { List<sObject> AccountsList = new List<sObject>(); AccountsList = [Select name from Account]...
0
votes
0answers
26 views

Want to Merge following SOQL

I want TO extract all picklist values for a field in a particular object. To get Durable ID of picklist Field : SELECT DurableId FROM EntityParticle WHERE Datatype= 'picklist'and EntityDefinition....
3
votes
1answer
60 views

Receiving a LWC error intermittently

Hoping someone can see something that I am not able to. Myself and other users get the following error intermittently, on some records this error appears and on others it does not. This LWC calls an ...
0
votes
2answers
22 views

Use field value with LAST_N_MONTHS

I am trying to accomplish something like the following: [SELECT Id, CustomMember__c, CreatedDate FROM CustomObject WHERE CreatedDate = LAST_N_MONTHS:CustomMember__r.CustomLevel__r.CustomPeriod__c ...
0
votes
2answers
52 views

Inline editing a datatable with related records

I have an accordion component that retrieves deal terms records. Each deal term has a payment schedule. My LWC pulls all the deal terms plus related payment schedules and displays on a page like ...
-1
votes
1answer
23 views

Please help to write a query to fetch ListEmails sent from a Campaign? [closed]

I tried this but it did not work please help me out. SELECT Id,ListEmail FROM where Campaign
1
vote
1answer
41 views

SFDX Salesforce CLI : Update a field to NULL

I have the following CSV of 12 Account records. As can be seen, I am deliberately setting the name to NULL for an Account record (highlighted). I am using the following SFDX/Salesforce CLI command to ...
1
vote
1answer
19 views

Query Contact.Email FROM Case while querying the CASE object

I am writing a callout=true function that will be calling an external service with some data collected from Salesforce. Since callout functions can't receive complex objects as arguments, and I have ...
1
vote
1answer
41 views

SFDX : SOQL Query/Output

I am currently learning Salesforce DX/CLI to pull in data from my org. I use the following syntax to extract Accounts data. sfdx force:data:soql:query -u vpy.lightninglearn@gmail.com --query "...
0
votes
1answer
61 views

Error in relational query in Apex

I have the following select statement, but it giving me errors. When I query separately it works. I tried under query editor also. Same error. List<Deposit_Detail__c> depositDetailList = [Select ...
-1
votes
1answer
28 views

execution of AfterUpdate caused by: System.QueryException: List has no rows for assignment to SObject External entry point

I have created a trigger to update the Priority of a custom object (JIRA_Issue__c) when the Priority of the related Case is updated. So Basically when a JIRA_Issue__c is created for a related Case, ...
0
votes
1answer
36 views

Query sibling records and throw an error if % greater than 100 [closed]

I have the Opportunity object with children records called Workshare__c. There is a field on Workshare__c that is a percent (Work_Share_percent__c). We don't have any rollup fields available on the ...
0
votes
1answer
22 views

Access Contact fields from Opportunity object

I'm showing up with another problem: I'm building a VF PDF page based on Opportunity object and I want to add a paragraph that shows all contacts related to this Opportunity. My approach was as ...
0
votes
1answer
43 views

SOQL query according to date in salesforce

My Requirement is "the records should be considered next only when they complete 12 months" and this is monthly exercise so if i query the data from database it should not include the ...
0
votes
1answer
25 views

User license expiration date

I want to know how I can fetch "user License Expiration date" using API. Could someone please help me with that. I have gone through similar questions and came to know that we can see that ...
0
votes
0answers
13 views

OpportunitySplitType SplitEntity picklist value record types

I am fetching the entity description for OpportunitySplitType through the rest api. For the picklist fields SplitEntity the documentation states: "The containing record type, such as an ...
0
votes
1answer
22 views

Is there a performance difference between Custom Settings vs Custom Objects? [closed]

Specifically, is it faster to query for a single record from a Custom Setting vs a Custom Object? Or is it about equal performance?
0
votes
1answer
21 views

Trying to get PermissionSet Name from PermissionSetAssignment SOQL in Apex

When I run SOQL in the query editor: SELECT Id, PermissionSet.Id, PermissionSet.Name FROM PermissionSetAssignment WHERE AssigneeId = 'xxxx' I'm able to get the PermissionSet.Name in the results. But ...
0
votes
1answer
14 views

Query records using REST API and POST method

Let's say I need to perform complex SOQL Query and there is unable to use GET with queryParams. Is it possible to use POST with query script inside the body? If so could anybody provide a simple ...
0
votes
1answer
32 views

SOQL query to get both direct and indirect contacts on an account?

Looking at expanding this trigger to auto add all related contacts, not just those directly related. Having a tough time figuring this one out. trigger InsertAccountContactsToOpportunityContactRole on ...
0
votes
1answer
32 views

How can i retrieve how many time a field with datatype (Lookup / Long Text Area ) being changed using SOQL on Case History?

Using this Soql : SELECT count(case.subject) FROM CaseHistory where field ='subject' i was able to retrieve number of time Subject field has changed Since we can not filter by OldValue / NewValue , ...
0
votes
1answer
20 views

How to Optimise code to retrieve user NickName by querying fields from a custom object

I have currently have a code that sends alerts to Head of Service(user) of a Business Unit. So if a case has been created for the business Unit APAC for example, an alert is sent the the Head of ...
0
votes
0answers
27 views

Heda - hed:too many soql queries: 201

I have a managed package ("Heda") - SF package for university usage. when I'm upserting many contacts (1000 to be precise) it throws me an error: System.LimitException: hed:Too many SOQL ...
0
votes
0answers
31 views

Trigger on child to update parent's field causes a process to fail

The certification object is the child and contact is the parent. They do not have a master-detail lookup relationship. The code seems to run here and there, but I get this error, i checked everywhere ...
0
votes
1answer
28 views

Why there are no entries in FieldPermissions table if a field is marked as Required in Setup?

I use query like below to find what Profiles and Permission Sets give what kind of permissions to a specific field: SELECT Parent.ProfileId, Parent.IsOwnedByProfile, ParentId, Parent.Label, Parent....
1
vote
1answer
30 views

User Can't See A Record From SOQL RESULT

I have a Lightning Page generated based on SOQL for different objects. The System Admins can see everything just fine. The other users cannot. I tried adding '...With Sharing...' to the APEX Class, ...
1
vote
1answer
23 views

Nested SOQL Not Working in Unit Test

I have the following code in my unit test to insert data: Account account = new Account(); account.Name = 'Account Name'; insert account; Opportunity opportunity = new Opportunity( Name = '...
0
votes
3answers
26 views

Is there a better way to soql B records by A's idList?

For example, first I will retrive a List of A sObject: List<A__c> A = [SELECT Id, Name FROM A__c WHERE ...]; Then I will retrieve a List of B sObject by A List like: List<String> idList = ...
0
votes
1answer
20 views

Data Mapped from controller is not visible in VF page

I have tried retrieving values of data from the controller and map them to the VF page. But, the mapped data is not being visible on the VF page, whereas in the debug of the controller it is visible. ...
0
votes
1answer
24 views

SOQL lookup query between standard and custom object does not work

Good morning, In the custom object Equipment_maintenance_item__c there is a lastModifiedById lookup field to the User object. My understanding is that User is the parent object, and that to query it ...
0
votes
1answer
56 views

SOQL to be outside of for loop [duplicate]

I am new to Apex and I am trying to make SOQL to be outside of FOR Loops but then my trigger stopped working. Here is my code: trigger AccountFieldUpdate on Contract (after insert, after update) { ...
0
votes
2answers
36 views

How to add AND operator in Dynamic query in SOQL query

queryStr+=clsList[0].G_Color_Code__c!=null ? ' AND G_Color_Code__c=\''+clsList[0].G_Color_Code__c+'\' AND \''+G_Color_Code__c=null+'\'': ' AND G_Color_Code__c=null' ; Here it throws an error ...
0
votes
0answers
25 views

What is the recommended way to filter a child object from the parent object through SOQL

I have a child object that I need to create which would be related to Opportunity. Let's call it RepPay. I wanted to know what is the best way to create this relationship for querying purposes which I ...
0
votes
1answer
69 views

How Can I Use SOQL to Query Multiple Unrelated Objects?

I have a Location object with a related list called Product Items on the Location. I would like to display the same Product Items on the Service Territory Member object. Service Territory Member has ...
0
votes
1answer
38 views

Malformed query expecting a right parentheses

I have a class that looks like this: public class NWTAttachCMController { private final static String urlFieldName = 'AttachNWTLetters__c'; private String partnerServerUrl; private ...
0
votes
1answer
25 views

Preserving changes to Inputfield on Pagination

I have a few Inputfields, that are populated dynamically. The number of Inputfields changes based on the "Product Family" Picklist field the user selects. I have buttons that enable ...
0
votes
1answer
15 views

How to find the last created/modified method(REST API or salesforce interface or something else) of an Event

How to find the last updated method of an event. My case is, I want to write a SOQL query to get the latest modified Events which are not updated via REST API. So i will get the collection of Events ...
0
votes
1answer
45 views

Can we call a Rest API method and retrieve more than 50,000 records in a Salesforce Environment? [duplicate]

I'm not sure how to phrase this question correctly, but the gist is that, an external party will access our Salesforce environment via REST Api and retrieve more than 50,000 account records. Now I ...
0
votes
0answers
46 views

How to map fields using custom metadata?

I have a requirement where i have two objects say, Product and Product line item(Both are custom objects). I have got a requirement where i need to map the fields in the product record to the product ...
0
votes
1answer
22 views

SOQL aggregate functions number fields

Trying to use an aggregate query to count certain records. Now I know that Number type fields cannot be used in Group By so I'm trying the following: SELECT Count(Id), Max(Number_Field__c) FROM ...
0
votes
0answers
25 views

Inputfields not recording changes

I have three Objects, Package_Item__c ,Product__c, Package__c. Package_Item__c fields - Name, Quantity__c, Product__c(lookup to Product__c), Package__c(Lookup to Package__c) Product__c fields - Name, ...
0
votes
1answer
24 views

Unable to Authorize Salesforce through Workbench

When I tried to validate salesforce via Workbench (https://workbench.developerforce.com/login.php), It is throwing me a weird Error : "An error has occurred and you have been logged out: Unknown ...
1
vote
1answer
27 views

Simple query of custom object returns zero rows in developer console

I'm working in the Dev Console, trying to help out a friend who needs a custom subset of data that his useless consult can't seem to figure out. I can successfully query the standard objects, but when ...
9
votes
1answer
59 views

Why the Sorting Logic in Salesforce SOQL and UI is VERY different from other Systems?

The ordering mechanisms in Salesforce are really odd. Take any SObject having any Text field (e.g. Name on Account) and create some Records. Do that on an Org with no other Records of the type (e.g. a ...

1
2 3 4 5
101