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

learn more… | top users | synonyms

1
vote
1answer
14 views

Send list in HTTP Request in particular order taking order by as row num?

Apex code: List<order_batch__c> bcList = new List<order_batch__c>(); bcList= [select ...
1
vote
1answer
11 views

Multi Value Results from Nested Query

I have a parent-child nested query like to this: SELECT Name,CloseDate,Theatre,(Select Product__c from Opportunity.OpportunityLineItems) from Opportunity where Name = 'Foo' The result of which, ...
1
vote
1answer
36 views

Force.com sites - public access to account/contact records

I have a force.com site, it has a visualforce page with a controller that is doing a very simple SOQL query to the database, which for some reason it's not returning any records. Here's what I've ...
3
votes
1answer
35 views

VF Performance Issue

Salesforce recently notified us that "a VF is consuming high levels of DB resources due to inefficient SOQL in your VF controller." I believe I have identified the issue down to this query: ...
1
vote
1answer
20 views

Salesforce not letting select country from a relationship, but allows name and id

I am running the following query in salesforce to get the country SELECt name, owner.country from lead This gives the following error: No such column 'country' on entity 'Name'. If you are ...
4
votes
1answer
54 views

System.QueryException: No Such Column - Strange RunAs Behavior with Summer '14?

Question Is there any known reason a SOQL Query would return a runtime System.QueryException on a custom field in test methods, in particular one one via a parent lookup in a test? I would have ...
5
votes
5answers
276 views

Why isn't a SOQL query of mine populating a list in an Apex test class?

Why does my taskOpp query below not return any records when I run this test? The query works fine in Workbench and my taskRT query works fine in both my code and in Workbench. public class ...
0
votes
1answer
16 views

Customer Portal User foreign key in Contacts?

When enabling Customer Portal access for a Contact, Salesforce creates a new Portal User for the person. I am creating an apex trigger for when the user creates a record in an object and would like to ...
1
vote
3answers
64 views

Pass result of SOQL query into a variable

I have the following query: public List<My_Main_Object__c> data; data = [Select My_Object__r.Id FROM My_Main_Object__c where id=:XXXX]; How can I pass the result of this query into a ...
0
votes
2answers
14 views

How can I query Orders to get OrderItems associated with that order

I see that there is a related list on Orders showing the OrderItems but there is not field on orders that I can SOQL query in Apex.
2
votes
3answers
168 views

How do I assign the returned query values to each Boolean?

If I have the following variables and query, how can assign the values of each field to their corresponding boolean? The fields are Checkboxes on the 'myObj' object. public with sharing class MyClass ...
0
votes
1answer
21 views

Programmatically determine relationship between two sObjects and generate result

I have an application which allows the user to specify a geography object and field. For example User's country field Account's State Field Now for Leads the system needs to dynamically determine ...
1
vote
1answer
39 views

Get the max value of a field with many records

I have a field that stores an ID, and I need to find the Max value of that field. However I get an error a queryexception. For reference, the field is set up as unique and external Id. Any ideas on ...
2
votes
1answer
83 views

Problem with deciphering query

I am new to a Salesforce organisation and currently I am trying to make sense of the organisation's apex code. I came across this query and for the life of me I can't figure out what it does. This is ...
7
votes
1answer
52 views

Get Count of ALL Records (All Objects) in Recycling Bin

Looking for a SOQL query (or some other method) to get a count of records in my orgs recyclying bin. I have seen other solutions posted suggesting to use the IsDeleted = TRUE and ALL ROWS to the SOQL ...
0
votes
2answers
39 views

SOQL Query for month operator

I have to compare month value of a custom object's date field, if it is of the current month. Please find the piece of code below. I am getting error here. Can someone help me? Code piece: ...
1
vote
1answer
30 views

Query the cases where case contact = logged in user's contact

for(Case c: [select id from case where ContactId = :UserInfo.getUserId]){ System.debug(c.user.Name); } Am not able to get logged user by case
1
vote
1answer
27 views

How do I use a field to populate the mail.setToAddresses in a sendEmail class

I have set up a class that sends an email and I am using a VF Email Template that uses the Oppertunity fields. I have set up a custom field called Proposals_Senders_Email__c that is a text field. I ...
2
votes
1answer
24 views

delete look up reference

I have two objects A and B. I have a look up reference of B on A. In certain cases, if the A has B reference, I would want to delete the look up it by making it null or blank, so that I can look up a ...
0
votes
1answer
20 views

Retrieving custom fields via QueryResult

I'm new to using SOQL and QueryResult. I'm using C# and the sample code from here: http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_quickstart_steps_walk_through_code.htm I'm trying ...
0
votes
2answers
20 views

How to retrieve latest Notes inserted to Custom Object

I have Custom Object that contains many Notes for each record.I want to retrieve the latest Note inserted for all the Records. List<CustomObject__c> = [select (select Body from Notes order by ...
1
vote
1answer
38 views

How to write a SOQL for a salesforce report

How do I get the SOQL query for this report?
2
votes
1answer
51 views

Dynamic SOQL for Cross-Objects

I am wondering if there is an easy way to dynamically query accounts based on the account having the primary FSE name attached to it. The Primary_FSE__c field is on the Installed Product Object, which ...
1
vote
1answer
47 views

SOQL Query on Opportunity-Account(Master detail)

Account acc; if(o.AccountId!=null) { acc = [select id,GUP_GUID__c,OwnerId from Account where Id = : o.AccountId]; } List<ECP__c> ecpList = [select id ...
3
votes
1answer
24 views

Owner custom fields and some standard fields are not accessible in relations

I am trying to access owner information using soql for managed packaged sobject. select id,ownerId,owner.name, owner.Email_Subscription__c from ARE__HavesWants__c I tried above query but it is ...
5
votes
1answer
113 views

SOQL Query to Group By Month and Year

Need help with a SOQL Query. We are trying to pull our highest sales records by month and user. Looking to see something like: "John Doe 100 Sales May 2014. Currently I am getting the calendar month, ...
0
votes
2answers
39 views

Accounts without Opportunities SOQL Query

I have a requirement to query for master objects that have no corresponding detail objects. This would be similar to querying for Accounts with no Opportunities. In SQL I might do this: SELECT Id ...
1
vote
2answers
18 views

How to get the referenced field's name value when the field is referencing multiple types

I'm using v31.0 of the Salesforce REST API. When looking at the metadata for some of my objects, Salesforce says that the OwnerId field references two tables: Group and User. The JSON that Salesforce ...
1
vote
1answer
18 views

SOQL - how to group by CALENDAR_MONTH

I am trying to create a custom chart in a visualforce page. I am using the results of a SOQL query as my data for the chart. I have this SOQL query: SELECT CALENDAR_MONTH(Hire_Date__c) ...
4
votes
1answer
91 views

Filter results with not like

I have to query task object to get the rows with subject not starting with 'Email' . I have tried the given query. But it is not working . Please suggest. select status, subject, whatId from task ...
1
vote
1answer
18 views

Join Query to a Batch Handler and processing the result rows

Can we write a join query and pass on to a batch handler. Once I get all the rows, I want to dynamically fetch values using their fields described from the rows containing info of both the objects. ...
4
votes
1answer
49 views

SOQL query filter WHERE by month

I have a custom object having a Date field Expense__Date__c I need to perform a soql query on the custom object where Expense__Date__c = THIS_MONTH So my query looks like List<CustomObj__c> ...
2
votes
1answer
47 views

Soql on multiple dates

I want to query on the task for multiple dates eg, date d3 = system.today().addDays(3); Select Id, Subject, WhoID, ActivityDate, OwnerId from Task where IsClosed = False and ActivityDate ...
3
votes
1answer
58 views

How to mock a SOQL query in Apex

Our Apex unit (true integration) test run takes about an hour to complete (260+ individual unit tests) and this really slows down our dev process as we are trying to adhere to Continuous ...
2
votes
2answers
41 views

Query LeadSource from Task

I am trying to write a SOQL query that queries from Task the field LeadSource. In a report the name of the field that displays LeadSource is Contact/Lead. I have been trying different variations like ...
0
votes
2answers
26 views

Query Account field IsExcludedFromRealign

There is a field on Account called IsExcludedFromRealign which determines that if Account is excluded from Territory Assignment or not. I am having an issue where some of my accounts are not assigned ...
1
vote
2answers
73 views

Error in loop iteration: 'Loop must iterate over a collection type'

Please find my code here. trigger PM1 on Account (after update) { List<Product_Metrics_vod__c> toDelete = new List<Product_Metrics_vod__c>(); set<id> ...
0
votes
1answer
40 views

Not Queryable field issue

I have to query on a non-queryable field here. Can someone suggest a workaround for this? Please find my code below. trigger PM on Account (after update) { for ( Account acc : Trigger.New ) { ...
1
vote
2answers
101 views

After update trigger issue

Please find my code below. trigger PM on Account (after update) { for ( Account acc : Trigger.New ) { List<Product_Metrics_vod__c> listCon = [Select ...
1
vote
1answer
25 views

RecordType Query - Multiple OR statemetns

I am trying to make a query for a recordtype id where the developerName can be different values. I am getting error expecting right square bracket, found 'OR' Set<Id>oppRecTypeSet = [select id ...
3
votes
2answers
38 views

Query on Task.Phone?

It looks like querying Task 'phone' is NOT supported. Can anyone confirm? I can get Owner.Phone, but not read the phone field itself. Acc. to this doc: Phone Phone number of the contact or ...
7
votes
3answers
185 views

SOQL Multiple COUNT 's with different conditions

I have tried a bunch of different ways of getting a result about the age in only one query. I want to count the contacts that are between 20 to 29 years old and count in another column the contacts ...
4
votes
4answers
104 views

Trying to get a SOQL query with no duplicates

EDIT: Is there a way where I could just loop through my list and remove the duplicates? It should be easy but I've been having trouble with it. I have tried a bunch of different methods of getting ...
1
vote
1answer
19 views

Trigger Not Getting Parent Object field values

This is the data model in our implementation. Parent : Case Child : Case_Search_Worklog__c The following code snippet tries to set the Case_Search_Worklog__c.COWnerEmail with the email from the ...
1
vote
1answer
19 views

SOQL - Viewing Parent Object field

A fresher question. I am unable to view the data either in the developer console or in the Eclipse IDE for the following query. Parent : Case Child : Case_Search_Worklog__c SELECT ...
2
votes
1answer
16 views

soql query on selfserviceuser

I wanted to get name of account from selfserviceuser object however getting error, I used below query : Select contactid, contact.account.name from selfserviceuser; Any guess what am I doing wrong ...
3
votes
1answer
55 views

SOQL query with Multi Select Picklist in where clause

I am trying to build a query in Apex code to fetch all records where a multi select picklist has either of 2 values selected. When I build my query and string as option 1 it does not return back any ...
5
votes
1answer
93 views

Too many SOQL queries error when converting Leads

I am new here and have no coding experience whatsoever. I am a Salesforce admin with 3 years experience. Before I started at my current company, they hired a consultant to create some APEX triggers. ...
1
vote
1answer
29 views

Trying to use a SOQL result as an HTML div id in visualforce page

Answer: I figured it out (or at least worked around it). I used document.getElementById(researcher).show; instead of $$(researcher).each(function(element) element.show(); and it works perfectly now. ...
0
votes
1answer
25 views

how to retrieve data based on created date and group them

I need to query the child objects and group them based on contact and created date example. customobject records queried based on account - gets me 100 records unique contacts among 100 records - ...