Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [soql]

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

0
votes
1answer
19 views

SOQL multipicklist contains value

I need to select a record from Salesforce and I have to use multi-picklist as a query condition. the one of the value from multi-picklist equals to 'some test' I need somehow to select by the ...
3
votes
4answers
39 views

What is the different between this 2 statement

i am new to APEX and wondering what is the different between the 2 statements below and which should be the best practice? 1) List<Contact> c1 = [select id, firstname from Contact]; for(...
2
votes
1answer
30 views

No such column 'CaseNumber' on entity 'Name' on SocialPost Object

I believe this ParentId is a lookup only to Case Object (Not polymorphic) I even check it using /services/data/v32.0/sobjects/SocialPost/describe
4
votes
1answer
74 views

Proper way to make Contract-Order, force 1-1 relationship

I'm looking out for a way to make the relationship between Order and Contract, 1-1, The relationship between both, is optional, but still, I'm unsure if I need to add a custom field to Contract that ...
-3
votes
1answer
30 views

Create a button that allows sending a message to the Contact of a custom Object

I have a custom Object Car__c. One of the fields in which is Lookup on Contact. When I filling this fields, I must provide the ability to send a message to the Contact that is selected in the current ...
0
votes
2answers
28 views

Query Account.Name in Opportunity SOQL

The following SOQL gives Account.Name perfectly in workbench: SELECT Id, Name, Account.Name FROM Opportunity The same when used inside Apex: for (Opportunity relatedOpp : [SELECT Id, Name, Account....
1
vote
1answer
21 views

Is it possible to get recordType from RecentlyViewed SOQL?

Is this possible? SELECT Name FROM RecentlyViewed WHERE Type = 'foo' and Type.RecordType.Name = 'bar' If yes, how should I go about it?
0
votes
1answer
33 views

How to access the records associated with a custom view in REST API

I would like to access the records related to contact predefined list views (like birthdays this week, contacts added this week), and custom views created by the user, using REST API. The SOQL query ...
7
votes
2answers
88 views

Throwing System.QueryException on Batch Class for field “IsArchived” on Product2

We're using Schema.getGlobalDescribe().get(objectName).getDescribe().fields.getMap()to fetch all the fields in Product2 and build a dynamic query. When the string is used in database.query() method, ...
1
vote
2answers
30 views

Access SOQL results by grouped field

I'm attempting to aggregate all ObjectPermissions at the user level for a user access review (audit) application. This application's central function is to show an end-user (a reviewer) their reviewee'...
1
vote
1answer
22 views

Get Task description with line breaks in SOQL

I have a lightning component that displays a List of Tasks in a sidebar. I use a SOQL query in the controller to fetch a List that fits the criteria and display them in the component. I manually model ...
1
vote
1answer
24 views

SOQL on feedpollvote object

Is it possible to write SOQL to display the Last Name and Choice of a user who participated in a Chatter poll. I have the following SOQL so far. I want the actual choice not the choice id. SELECT id,...
0
votes
1answer
16 views

Bubbling up an Account hierarchy to capture top most Parent Id from query

Based on some of the answers I've browsed I think this might involve 2 queries. I feel like this is probably a pretty common problem so I was hoping someone would have a quick answer or at least be ...
0
votes
1answer
29 views

How do I architect my code to avoid this “Too many SOQL queries: 101”

I am developing some apex code that I am using to query a REST web service and storing resulting objects in salesforce. I know that this error means that I am generating more than the 100 queries ...
1
vote
1answer
16 views

How to use VSCode to find which reports are using a specific field

I have used Eclipse in the past but unfortunately, Eclipse and Force.com IDE no longer work for me. I have switched over to VSCode along with the Salesforce DX and forcecode extensions (among many ...
0
votes
0answers
36 views

Schedule apex class to run every day

I want to make some rollups on a custom objects via a scheduled Apex class. I managed to test the rollup via an Apex trigger, which fired whenever I edited the custom object. Now I want to run it ...
0
votes
1answer
22 views

Operator like is not supported on an encrypted field

We are querying Salesforce using SOQL, if the encryption is enabled for the field that is used in query, we are getting the following error. Operator like is not supported on an encrypted field Is ...
0
votes
2answers
24 views

SOQL query to identify Account names with out any number

I require to grab all account names which does not contain any number and display in the report. I am trying to query it using LIKE, but it is not working. My query - [select name from account where ...
0
votes
1answer
19 views

Adding Additional Fields to a sObject in Apex, (just for manipulation)

I'm working with some complicated queries, and I need to send over http, the sObject in turn, but I can't make queries with more than 1 level of depth in the SOQL, so I am working with separated ...
0
votes
1answer
39 views

SQL Query is not retrieving data

I am trying to run below query, which successfully run but it does not retrieving any data. I am 100% confident it should retrieve the data as I have manually checked. What could be the reasons its ...
2
votes
1answer
64 views

Best practice using Schema.SObjectType

Wants to know please, 1) Why using the Schema.SObjectType is better than using a SOQL? 2) If using the Schema.SObjectType inside a for loop is a bad Idea... for example: Id devRecordTypeId = Schema....
0
votes
0answers
22 views

I would like to specify conditions for receiving Push notifications

I would like to receive a push notification only when the information on the case I currently see in the browser has been updated. I want to realize the following. SELECT Id,Status FROM Case WHERE ...
0
votes
1answer
10 views

Trouble with lookup relationship parent query

I'm trying to construct a query that takes a specific Contract with a provided Id, and I want to fetch from this record, the related Order's, and their OrderItem's, So If I understand correctly I ...
2
votes
1answer
23 views

[SOQL]: Reference Id field on a custom object without dot notation?

I know that with standard objects one can do AccountId instead of Account.Id inside a SOQL query. Is it possible to do the same for custom objects, say for My_Object__c? Is there a way to reference ...
2
votes
1answer
24 views

Count the number A-Objects that have B-Object as a a foreign key

I have two custom objects, Students and Coaches, where Students have a Coach__c lookup field. I am attempting to write a trigger that when a new Student is created, I need to assign that student a ...
0
votes
0answers
27 views

Neste SOQL query [on hold]

I have a problem with nesting SOQLS. I have a two accounts in relation, person FO and company FOP By this select, i will select product on the FOP account and related FO account SELECT Id, Account....
0
votes
2answers
32 views

How to get DataCategory name and not Unique name from Knowledge Base with SOQL?

I started using the Knowledge base and i want to pull out all the knowledge base category group names from it.  I am using the following SOQL statement: Select Id, Question__c, Answer__c, (Select ...
2
votes
1answer
58 views

Query if user has community access?

I want to implement the selfreg Napili community form of salesforce for that I want to add a step "If User has a user than to redirect to the 'forgot password' page" So I need a step to ask ...
0
votes
1answer
19 views

Not able to access ContentDocumentLink on Site VF page's Controller(without sharing)

SOQL: [SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId = {{reocrdID}}] OR SELECT Id, (SELECT ContentDocumentId FROM ContentDocumentLinks) FROM {{sObjectAPIName}} Where id = {{...
2
votes
2answers
485 views

FOR Loop NOT being executed w/ NO errors

The trigger is firing, there are no errors, and it is running through all of the code, except the FOR loop w/ the SOQL query. THE QUESTION Why is the trigger not jumping into the FOR loop? THE ...
2
votes
1answer
25 views

Is there a way to query exclusively the fields in the Page Layout for an sObject via APEX?

I've been looking in to the ui-api but it doesn't cut it for me, what I need It's to return exclusively the fields in the Page Layout for an object and some additional records. Something like ...
2
votes
1answer
46 views

SOQL in Apex trigger returns [Name Set by Trigger]

Have 2 managed packages. One package contains Recurring object. Another package contains Receipt object. Opportunity has lookup fields to Recurring object and to Receipt. Created text field '...
-2
votes
1answer
33 views

Synchronous vs Asynchronous Salesforce

What is Synchronous and Asynchronous execution in Salesforce? Can anyone explain? I saw in governor limits Total Soql Queries in Synchronous is 100 and in Asynchronous is 200 What is Synchronous ...
1
vote
1answer
34 views

Accessing fields from inner query [closed]

Below is my query SELECT id,(SELECT id,ServiceResourceId, ServiceAppointmentId FROM ServiceResources), ParentRecordId FROM serviceappointment This is the result of what it looks like in the dev ...
1
vote
0answers
22 views

Contacts with MiddleName values and queries

As per this previous question, I believe that Salesforce (still!) has a bug in querying Contact instances when middle names are enabled and set. If I have a Contact with FirstName "Mohammed", ...
1
vote
1answer
42 views

How can I know number of records of All Salesforce Object?

I have written a small Apex class to fetch list of all available (Standard+Custom) Objects in Org and their fields. But when trying to retrieve total record of individual Object, this is showing too ...
0
votes
1answer
34 views

Query All Opportunities With the Same Owner ID

I am working on something I thought would be pretty easy. My Idea was to calculate the win rate of the opportunity owner and display it in a field on the opportunity record. My first thought was an ...
2
votes
1answer
25 views

How to retrieve activities using SOQL?

I like to retrieve activities of an account using SOQL like: Past Activities - <Date> Email: <subject>, John A. sent an email to David K. - <Date> Email: <subject>, Brian G....
0
votes
1answer
24 views

SOQL query return one field as null during run in another apex class

Hopefully someone has any idea about this issue because im ripping my hair out. My goal is to add the field OCR__c on the campaignMember to a PDF. The PDF is generated and all fields except the ...
0
votes
2answers
19 views

API Issue with SOQL for Knowledge

I have a Knowledge object which I'm trying to run a SOQL against. Running SELECT Title FROM Knowledge__kav, I receive: Got a RESTError(status=Bad Request, code=ERR-0002, message=[ValidationError{...
0
votes
1answer
17 views

How to filter n days from a specific day in SOQL?

I need to write a soql which is filtering last n ndays from a specific day. Is that possible to write a soql query something like below? SELECT Name FROM Account WHERE CreatedDate <= (2017-12-...
0
votes
1answer
16 views

Check if string element is present in custom metadata type list

I have a list of custom metadata type. I need to check if the string element is present in custom metadata type. Currently, I'm hardcoding the browser name in my if condition, but I need to compare ...
1
vote
1answer
28 views

How to perform SOQL query after retrieving access_token and instance_url via oAuth2 flow?

I have successfully setup my oAuth2 flow, created a Connected App and I can retrieve an access_token and instance_url just fine. Now that I have those two pieces of data, how can I perform SOQL ...
3
votes
1answer
89 views

Select aggregate into Integer using Database.query()

So we all know we can put an aggregate directly into an Integer, like this: Integer countAccounts = [SELECT COUNT() FROM Account]; Is it possible to do the same thing, using Database.query()? ...
1
vote
1answer
13 views

Can we use managed package child relationships in our apex code?

I have 2 Managed package custom objects workcalnder(pse__Work_Calendar__c) and holiday(pse__HolidayObj__c) and their is lookup relationship between them. WorkCalnder is parent and holiday is child. ...
0
votes
1answer
30 views

Convert the content of sobject into the list of Id

I have an invoice Object which is connected to contact through case. I have a list of invoices which contain list of contactIds. This is what I have done: List <Invoice__c> lstInv = [select ...
1
vote
1answer
107 views

First error: Query of LOB fields caused heap usage to exceed limit

I simply try to execute a batch job and execute a SOQL inside the execute() method as below with having, execute() method has the line List results = (List)database.query(query); , and start() ...
1
vote
1answer
20 views

Cleanse Data on opportunity Contact Role

I have inherited an org with a trigger which was creating duplicate opportunity contact roles. I have fixed the issue of the duplication but there are lot of OCR records which are duplicate. i want to ...
1
vote
2answers
63 views

Cannot move query outside of FOR loop?

REQUIREMENT: Need to move the query outside of the FOR loop in Opportunity trigger. PROBLEM: After moving query outside of the FOR loop, I receive an error when trying to save a new Opportunity ...
0
votes
1answer
27 views

For Loop - Query Account Object from List of Contacts

I am trying to extract the email domain from each contact record from the email address field and use it to query for matching values on the account record. How do I loop over a list of contact ...