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
16 views

How to do a SOQL Query of DAY_ONLY on a DateTime field?

Here is the problem. We use Stripe to process credit card payments, and Stripe deposits the money into our account two days later, minus fees. I've created a schedulable class that runs every ...
1
vote
1answer
21 views

Content cannot be displayed: Illegal assignment from List<QuoteLineItem> to List<QuoteLineItem>

In our org's STAGE environment, I ran the following code anonymously in the dev console, intending to clear data from a pair of custom fields for ~400 QuoteLineItem records. void clearOStatusAmtPd() ...
-1
votes
1answer
28 views

SOQL query all tasks and events with opportunities and any connected campaigns

I'm fairly new to SOQL but I need to write a query that returns all activities (Events and Tasks) that are associated with an opportunity. In addition I'd like to get any campaigns that are ...
2
votes
0answers
12 views

Automatic re-naming of bind variable in Execute Anonymous debug log - why did/does this happen?

I have a simple execute anon script, which outputs something unexpected. Execute anon script Id accountId = '0012500000EJiaG'; List<Account> accountList = [SELECT Id, Name FROM Account ...
0
votes
2answers
13 views

Query of Tasks for Custom Object

I have a list of Custom Objects, created by customers each day - they can be considered like trouble tickets. Against each one, is a Task created when our agents make an outbound call back to the ...
-1
votes
1answer
24 views

Parent to child traversal more than 1 level

I have to traverse from Account->opportunity->opportunitylineitem->product.family. I think this can be achieved by map, but i have very less idea on map please help. I am accessing this from the ...
0
votes
1answer
36 views

Fatal problem with otherwise working code. Please help!

this code is meant to suggest a property to a lead based on some of the entered criteria. It is working, but there is a fatal problem. When I do a mass update of lead records, instead of the trigger ...
1
vote
0answers
8 views

Ajax Tools App Exchange dojo.js not found

Whenever I try to use Ajax Tools installed in any of my Dev Orgs and load it's Explorer tool, I receive a 404 (Not Found) error message preventing me from using the SOQL builder tool that's built into ...
0
votes
1answer
25 views

Sorting by two columns in VF page controller

List<Small_Capital_Field_PM__c> lstSmallCapital = [Select Name, Account__c, Account__r.Name, CFN__c, ...
1
vote
1answer
42 views

SOQL query to get records from two independent objects

I have a requirement to create a report. I have three Objects : Contact, Order and Lead. Order is lookup to contact. Lead has no relation with any of these. I need to create a report with some ...
-1
votes
1answer
25 views

How to write formula criteria in SOQL?

I'm using a app from the app exchange and it requires the criteria for the field (rollup summary field) to be written in SOQL, and I have no idea how to write criteria that way. Can anyone help me? ...
0
votes
1answer
14 views

Bulk API - Invalid field 'Revision' on FeedItem

I query FeedItem on all fields using Bulk-API. This is the query: SELECT Id, ParentId, Type, CreatedById, CreatedDate, IsDeleted, LastModifiedDate, SystemModstamp, Revision, LastEditById, ...
4
votes
2answers
58 views

Retrieve a list of Cases from Accounts SOQL

I am trying to get a list of all Accounts with their related Cases. There is a lookup on the Case object to Account (AccountId). Right now I have to do two queries: List<Account> stores = [ ...
9
votes
1answer
139 views

Aggregate SOQL - How Many Fields Can Be Grouped?

As stated in the title, is there any maximum on the number of fields that can be passed into a GROUP BY clause? I can't find any documentation on it. For example, if I had the following query: SELECT ...
2
votes
1answer
20 views

Query First Task On An Account Using AccountID

I am trying to write a SOQL query that will return the first task that was completed on an account. SELECT Id, ( SELECT id, subject, type, CreatedDate from Tasks WHERE TYPE IN ('Phone Call', 'Email') ...
0
votes
1answer
26 views

How to get the label of a field Soql [on hold]

I am doing a remote action in which I am getting a soql result return to js. Now in my js i am displaying a list of records but with the record I want to display the field label not the api name. How ...
0
votes
1answer
22 views

Bad request on Query `FIND {aa-bb.cc.com} IN EMAIL FIELDS RETURNING Account`, maybe due to dash

Using salesforce webservices (REST API), this query works: https://xxx.salesforce.com/services/data/v33.0/search/?q=FIND%20%7Baabb%40cc.com%7D%20IN%20EMAIL%20FIELDS%20RETURNING%20Account URL ...
0
votes
1answer
35 views

How to query recent approver name from Approval history?

How to get a recent Approver Name (only Recent Step Approver Name ) from Approval History. I am trying using below SOQL this but no success: SELECT id, p.NodeStatus ...
6
votes
1answer
81 views

Single SOQL query for Accounts without Contacts

How to query those Account which has not any related Contacts ? I have Queried Account and contact in inner query. I found All Account with that Account I looped and find those Account whose Contact ...
-1
votes
3answers
37 views

Inner Query for lookup relationship is not working

I am trying the below inner query for lookup relationship on Account created for detail__c : http://imgur.com/etqYEPo List<Account> detailObj = new List<Account>([select id, (select id ...
-1
votes
2answers
29 views

database force commit insert transaction when exception thrown

How do I force my database transaction when a exception is thrown. I am trying to insert a record in finally block but throwing an exception in catch block. try { ... } catch(Exception e) { throw e; ...
1
vote
0answers
28 views

SOQL custom string in Column list

I am running the query SELECT Id, BodyLength, Body, Description FROM Attachment WHERE SystemModStamp <= 2015-08-27T15:48:25.403Z and storing the response in SOAP API. I need to ignore the ...
0
votes
0answers
44 views

SOQL By Date, Including 1 previous record [closed]

I have a beforeInsert & beforeUpdate trigger that needs to use previous record (based on identical Product__c), and I need to set a Custom_Field__c field equal to the previous records ...
3
votes
2answers
92 views

How can I map a relationship between 3 sets of Values?

Is there a way that I can create some type of Map between 3 objects in a trigger? I need to map (sObject, Date, Decimal) I know this may not be possible in a single map, but is there a workaround ...
4
votes
0answers
44 views

Trigger Design Question - Help Appreciated

A bit of context: Our company sells vacation rentals and has over 60 properties. When a customer chooses a property, it is stored in a look-up field called Lead.Property__c. They will also choose ...
-1
votes
1answer
30 views

How Can I Perform DML Operations insert,update,delete records of an Object Using JS(client-side controller) and Apex(server-side controler)

I am very new in Salesforce, What i want is to have a complete explanation and code example in how to insert,update,delete multiple or single records of an object. Using Apex Server Side Controller ...
0
votes
1answer
38 views

Trigger SOQL Question

I have a SOQL query that puts values into a map. In the main function of the trigger,(which lives within a for loop) I would like to clear() the original map, and re-run the same SOQL query, resulting ...
0
votes
1answer
37 views

SOQL query in a javascript button

On Contract object, i have a javascript button, which is supposed to pass the ID the related opportunity and account as a parameter to a page. How do i handle scenarios where SOQL query fails to ...
2
votes
3answers
33 views

SObject row was retrieved via SOQL without querying the requested field: Contract.Account

i'm trying to build query Dynamically for Contract object. public Contract con {get;set;} ConId=ApexPages.CurrentPage().getParameters().get('ConId'); Map<String,Schema.SObjectType> ...
2
votes
1answer
43 views

SOQL Dynamic Query building using Map.get(List)

I have a doubt. Suppose I want to query on Account object filtering based on a given list of IDs. Below snippet works fine when I have a list of Ids. List<String> accountIds = new ...
2
votes
2answers
37 views

Update ApexClass/ApexTrigger/ApexPages code using DML Not Allowed

I am trying very simple thing I just want to update any ApexClass, Apex Trigger, or Apex Pages code using DML operation something like. ApexClass mApexClass =[Select body, version from ApexClass ...
-1
votes
1answer
31 views

SOQL for Many to Many Relationship

I have a many to many relationship between Opportunity and custom_object__c with the junction object junction_object__c. Now I have to frame a query to pull all the related/attached ...
-1
votes
1answer
20 views

ORDER BY a String which contains a number [duplicate]

I'm trying to 'ORDER BY' a String field which contains numbers. It orders like this: 1 10 2 3 ... I've tried whith LPAD, VALUE, *1, but nothing works. THANKS all for ur help!
3
votes
1answer
36 views

How to use soql queries on multiple look up relationship object to retrieve specific data

I have 4 custom objects (as shown in the schema diagram). And they are associated using a lookup relationship. Now the objective of my question is to retrieve Product profile(product) for a given ...
0
votes
1answer
20 views

Aggregate Query Returns Results in Dev Console but not Apex

I have an Apex Class that retrieves an aggregate result of Contacts per Accounts in order to validate a maximum of 2 Contacts of a certain type. I have tried several things. First I used a set and ...
2
votes
1answer
39 views

Inner SOQL child to parent query

I have written the below parent to child inner query which works : List<master__c> masterObj = new List<master__c>([Select id, (Select ID FROM detail__r) FROM Master__c]); Which ...
1
vote
0answers
35 views

How to write a SOQL query to order by records a user has ever modified?

Imagine I'm building a ticketing system and I want agents to automatically receive the "next" Ticket__c. However, I want to be smart about what comes next by adding some kind of best effort stickiness ...
0
votes
1answer
85 views

Check to see if the record exists - APEX

EDIT: Map.ContainsKey is not working correctly and here are the details: in my assetRoles i have the following one record: DEBUG|assetRoles {a0Gj000000Oni9NEBR=Asset_Role__c:{Id=a0Gj000000Oni9NEBR, ...
1
vote
1answer
26 views

SOQL to pull the Account ,Contact,OppLineItem details on Opp in a single Query

I'm trying to frame a single SOQL on opportunity with fields from Multiple objects like Account Name, Contact Name ,Contact Ph , Contact Email and the Opplineitems. I'm not sure how to get the Account ...
-1
votes
1answer
24 views

Invalid bind expression type of Datetime for column of type Date

for(Sample_Limit_vod__c SL : [select Account_vod__c, Product_vod__c, Disbursed_Quantity_vod__c, ...
0
votes
2answers
17 views

Inner query in soql can only happen for master-detail relationship or also for lookup relationship?

Inner query in soql can only happen for master-detail relationship or also for lookup relationship? Inner query in case of master detail as below : SELECT ID, (SELECT Amount FROM Opportunity) FROM ...
-1
votes
1answer
28 views

How to query another Objects field to get it's value

How do I query the value of Contact.Country__c? It is to be connected with Case. For now my code is: @isTest public class WebToCaseCountryTest { public static testMethod void testTrigger() ...
5
votes
2answers
64 views

SOQL Query of lookup relationship

I have an SObject called Team_Member__c It has a lookup field Manager__c pointing to Team_Member__c, so the Team_Member__c SObject is related to itself. The relationship represents a management ...
0
votes
2answers
26 views

Last Modified date between 30 and 60 days formula

I have a requirement where I have to write a query with a condition that the Last Modified date should be between 30 and 60 days and this should be configurable by user. I have created a custom ...
1
vote
1answer
25 views

SOQL query to exclude the deleted file from feeditem

I'm trying to display the feeditems with attachments in VF page. I'm trying to query the Feeditem using the following query. SELECT id, ContentFileName, ContentSize, CreatedDate FROM FeedItem WHERE ...
2
votes
1answer
19 views

Incremental SOQL vs SOAP API calls

I am retrieving records that have been updated/deleted after every backup, i.e. Incremental backup procedure. There are different options to pursue with this: Bulk - Cannot support all the objects ...
3
votes
1answer
31 views

SOQL query to get the column which is not in the group by clause

Lets say the below records exist in the CampaignMember table: +------+------------+--------+-------------+ | Id | CampaignId | LeadId | CreatedDate | +------+------------+--------+-------------+ | ...
0
votes
2answers
46 views

SOQL for-loop - best practice

I'm not sure if I'm following the best practice and below is my code and can this code be done in a better way? for (Id assetNewId : RightOptionMap.keySet()) { boolean flag = false; ...
1
vote
0answers
20 views

How to Reference campaign object from Lead? [duplicate]

Salesforce Enterprise WSDL downloaded from my organization shows that there is Campaign reference on Lead object: <complexType name="Lead"> <complexContent> ...
4
votes
2answers
35 views

SOQL Query to retrieve Contacts from an Account sorted by the distance between the contact location and the account location

I'm trying to create a SOQL query to retrieve Contacts from Accounts, with the contacts for each account sorted by the distance between the contact location and the account location. This is what I ...