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

learn more… | top users | synonyms

1
vote
2answers
12 views

Query for ApexClass?

I'm trying to create a query where I want to search Apexclass and ApexPages . At present I'm able to search by Apex class,I'm trying to search for Apex class but did not worked.The object for class ...
1
vote
1answer
13 views

Filter by OwnerId is not working

I'm stucked with an issue. What is wanted is to filter search by Subject,Status,ActivityDate.It is filtering , now i want to filter by one more field "OwnerId" here.How do i go about this ? Any ...
1
vote
1answer
9 views

Apex UPDATE result is not visible by SELECT happening afterwards

A question to those who may have some background over Salesforce stack. I would like to confirm if my suspicions may be right. In APEX controller I'm doing following set of operations: setting ...
3
votes
1answer
43 views

Need Help for Salesforce SOQL for Get Record in Date Range

i need help for my SOQL. i have employee custom object with this information Employee table i want to select the employee information about total employee per department per month to date, for ...
0
votes
0answers
8 views

Is it possible to have auto populate table from another table in Salesforce?

I have one table structure like below.Actually I simplified the table to make it easier to explain. =) Year__c Column1 Colum2 FY2014 200 250 FY2014 150 1000 FY2014 81 123 FY2014 0 ...
1
vote
1answer
25 views

Visualforce: How to render multiple records, 1/page in a single PDF

I would like to render PDF page base on the amount of record I retrieve using SOQL. example If I have 10 invoice forms, I should be able to render 10 pages in 1 PDF.
2
votes
1answer
59 views

Export to excel file problem with displaying information

Following is my page <apex:page controller="contactquery" contentType="application/vnd.ms-excel#SalesForceExport.xls" cache="true"> <apex:pageBlock title="Export Results" > ...
2
votes
1answer
11 views

Query Opportunity join on Partner account lookup (Join two quries)

I have two queries, how can I join both together into one SOQL? SELECT o.Partner_Account__c, o.id, o.name, o.Account.Id, from Opportunity o SELECT a.id, a.name from account a where a.id = ...
2
votes
2answers
97 views

How can I query parent to child with two child values and no other child values?

I have one parent "quote__c" and child object "Quote_line_item__c" .I want get the parent id with query some thing like this select id,(select name from quote_line_item__c where name='123' and ...
2
votes
1answer
38 views

SOQL query DATE comparison

How do I compare a date field? I have 2 objects ObjectA and ObjectB and I would like to run a query for ObjectB that is DateFieldB = DateFieldA. Here is my Line: for(ObjectA__c A : Trigger.New) { ...
3
votes
2answers
91 views

Get parent records with 0 children in SOQL

So this would be possible with a roll-up summary, but since there's a limit on the number of these available, I'm trying to accomplish it without the roll-up summary field. Via SOQL I need to get a ...
0
votes
2answers
26 views

Replace SOQL query in for loop with method call?

I have a for loop structured in the following way: //MAIN CLASS for (List<My_Data__c> myData : [soql_query]) { code_block } Can I pull the soql query out of the loop, place it in another ...
1
vote
1answer
28 views

Timeout for soql in sandbox

I am trying to run a few queries on the Event object.But the queries time out. Querying the same in Full copy sandbox seems to be okay. But the time out happens in Production only. What could be the ...
4
votes
2answers
69 views

Apex CPU Time limit in Batch start() - is this a Query Timeout and how to cope with?

I have a Batch iterating over a large amount of records (with many fields) and 2 of their related child records. The start() method uses Dynamic SOQL to fetch them via QueryLocator to vary which ...
0
votes
1answer
34 views

Error in query for multiple fields

When i write 'Select Id, Subject,Status from Task where Subject like \'%'+searchText+'%\' OR Status like \'%'+searchText+'%\' Order By Subject,Status'; it is working but when i include OR ...
2
votes
1answer
22 views

How to check for existence of record?

I have the following piece of code: AccountMarket__c match = [select Id, Name, Account__r.Name, Market__r.Name from AccountMarket__c where ...
2
votes
1answer
17 views

Select with join Account and User table

first time I have needed to do a join in soql and I'm lost. in MySQL it would be Select AccountId, Account.ParentId, Account.Dealer_ID__c, User.Name FROM Account LEFT JOIN User on ...
2
votes
1answer
22 views

Query to find out duplicate records on two fields

I need to figure out the list of duplicate records based on two fields. That means suppose we have two duplicate records a and b, a.field_a__c = b.field_a__c and a.field_b__c = b.field_b__c and a.id ...
2
votes
1answer
25 views

Help needed getting set of child object IDs in a trigger

I have a set which I want to populate with child record ID's set <custom_object_name__c> ids = new set <custom_object_name__c>(); for (Opportunity opp : Trigger.new) ...
0
votes
3answers
38 views

One query to count # of Oppos Closed Won and # Closed Lost

How do i get this into one query ? I need to count total no of opportunities which are closed won and closed lost . Have written two queries and want to make it one with one variables . public ...
1
vote
2answers
28 views

Is this query correct?

Case oldRequestownerid=[SELECT OwnerId FROM case WHERE OwnerId =: Trigger.oldMap.get(d.Id).OwnerId ]; This query is written ...
2
votes
2answers
37 views

Optimize SOQL response time when Where clause references a formula field

I am creating a dashboard, and for example a Formula field will identify if the record has issues. I know that Formula fields are not indexed in SOQL. Can anybody tell what's the best approach in this ...
6
votes
2answers
32 views

Getting the right converted currency in SOQL

What is the right way to get the converted currency in SOQL? I've got this in my query: SELECT Owner.UserRole.Name, Id, Name, Include_in_Forecast__c, convertCurrency(Amount) FROM Opportunity ...
1
vote
0answers
12 views

Query the Partner Community Account via SOQL

I was updating test classes in our org to get more code coverage and stumbled upon all those obviously being for our partner community. Now there is this SiteRegisterController, which the Salesforce ...
0
votes
1answer
60 views

Constructor executing more than once

I am stuck and not able to find out why it is not working. My constructor is getting executed 5 times which is creating problem for me. <apex:page Controller="PrtnerMonthlyReport" sidebar="true" ...
1
vote
0answers
17 views

Knowledge Article Version not being retrieved through an SOQL on Site

I am trying to query the Knowledge Article Version object based on a list of Knowledge Article IDs that I have. The query seems to be working fine if I run it on the org or in the code, however when ...
0
votes
1answer
23 views

Getting SObject row was retrieved via SOQL without querying the requested field when trying to reassign approval request

I got the following error when trying to reassign the approval in the quote reassign approval request. SObject row was retrieved via SOQL without querying the requested field: ...
7
votes
0answers
108 views

Weird missing record issue with SOQL query

Can someone help me understand why this query is returning 1 less record than expected when a Date custom field (Due_Date__c) is included in the SELECT clause? As you can see in the screenshot, it's ...
3
votes
1answer
44 views

How to bulkify a trigger that has unrelated objects

I'm trying to bulkify a trigger, previously when I've done this there has been a relationship between the objects within the trigger and i've been able to figure it out from other peoples triggers. ...
0
votes
0answers
36 views

Unknown Exception. Too many Query rows

I have 3 SOQL Queries running in an Apex class. I'm using the related VF page in Force.com sites. When this code runs, it is throwing an exception on the page. No exception is caught in debug logs. ...
0
votes
1answer
27 views

SOQL Includes with Field Value?

I'd like to add a FROM Account WHERE Clients_for_Job_Opportunities__c INCLUDES (AVTRRT__Job__c.Account.Name) line to my SOQL query but at the moment it looks like I can only add static values. So ...
2
votes
1answer
61 views

SOQL done right. SOQL-Injection secure

I was looking for some reassurance that all that needs to be done (and its best practice) when doing dynamic SOQL is to use escapeSingleQuotes. There was a query like this string query = 'SELECT ' + ...
1
vote
1answer
35 views

How to accept InputField to filter a query and then display results

To save you a search, similar examples exist at how to pass value from visual force page (InputField) to controller? and ...
2
votes
1answer
35 views

validation rule to stop delete

I know this sounds a bit strange but I want to stop a deletion call so that I can test an error handler on my visualforce page. How can I go about setting up a validation rule that will stop a delete ...
2
votes
1answer
39 views

Non Selective Query issue

I m getting the following error in a trigger. Error:Apex trigger ContactSumTrigger caused an unexpected exception, contact your administrator: ContactSumTrigger: execution of AfterUpdate ...
4
votes
1answer
77 views

Can you do a SOQL Query on a Hierarchical Custom Setting?

I have a Hierarchical Custom Setting that I need to SOQL use a SOQL query for using the current User's Profile. Currently I'm using the getInstance() method with the User Profile ID to get the custom ...
0
votes
3answers
64 views

Unsure how to do this join

I can't fathom how to structure this query, by the end I want to be able to use the following without getting a null exception: for (Contract_Item__c cli : lineItems) { if ...
1
vote
3answers
37 views

Owner userRole name is not accessible

Heyy All, I was trying to pull the role name and tried following query - Select id, owner.userRole.Name from opportunity where stagename = 'closedWon' However when i try this simple query in ...
2
votes
2answers
29 views

Is it possible to use SOQL to query a list that was created in a trigger

Does a SOQL query have to access the database, or can it be used to search through a list (or map)? I think lists are easier to visualize, so I would have made a list in a FOR loop for each object ...
1
vote
1answer
24 views

Help comparing CreatedDate with a specific Date

can anybody help me with this query, i am trying to get records from 1/1/2014 i don't know how to do the right comparison. I will appreciate any help. Date d = date.newInstance(2014, 1, 1); ...
9
votes
1answer
132 views

Does SOQL SUM(CurrencyField__c) calculate correctly in MultiCurrency Org and how?

I have a managed travel expense app with an AggregateResult SOQL that sums up Expenses per Day. All expenses can have different currencies and don't have to match the corporate nor the current users ...
1
vote
3answers
45 views

Illegal assigment from LIST<custom_object>

I am fairly new to Salesforce, I have a trigger which requires a test method for it to meet its code coverage. I am getting errors in the test class stating Error: Compile Error: Illegal ...
3
votes
1answer
33 views

Apex returning rows but no data

I have created a simple VF page with an Apex controller which fetches records from a custom object. The VF page displays the correct number of rows but no data is returned. I know that it is getting ...
1
vote
2answers
67 views

SOQl query to compare multiselect picklist with a variable

I have a string field says ServiceSegment = 'A' and a multiselect picklist Service_segment__c ='A;B;C'. I want to write a SOQL query which can compate string field to multiselect picklist. I tried ...
0
votes
0answers
62 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 ...
3
votes
2answers
54 views

Date literals not working in batch apex?

SOQL: [SELECT Id,Name FROM Account WHERE createddate=THIS_MONTH] This query is working fine when it is called from button, but it is unable to filter according to the created date when it is ...
0
votes
1answer
68 views

How can I replace a SOQL in a loop by a list?

I am hitting the governor limits on Event object and I need to change some lines in my Apex Class to avoid SOQL statements in For Loops. I got this affirmation from the support. Someone could help me ...
3
votes
2answers
58 views

SOQL Query Trigger loading time

I am writing a trigger for when a Lead is inserted, I want to query all of our org's Contacts to ensure that the Lead's email does not already exist under a Contact. I am using: List<Contact> ...
7
votes
2answers
74 views

Doing query as specific user

Situation: We are doing SOAP API (custom made apex webservice) calls to service using admin user. Those calls do search on Accounts (millions of records, search mostly on Name field) Account are ...
3
votes
2answers
64 views

Understanding 'List has no rows for assignment to SObject' in a trigger creating new record on custom object

I'm having an issue with my Apex Test Class from a trigger. I've used the trigger multiple times in my sandbox but when I try to test it out it fails. The reason for the failure is ...