Questions tagged [soql]

SOQL is the Salesforce Object Query Language.

SOQL, the Salesforce Object Query Language is a SQL like syntax used on the force.com platform to query records within a Salesforce instance. It can be used in triggers, or fully fledged Apex code, or via their web services API.

748 questions
1
vote
0 answers

Upserting Salesforce Users based on 'Username' gives DUPLICATE_USERNAME error

A simple question, I am attempting to Upsert User records into Salesforce by using 'Username' as the External Id. But I am receiving the following 'DUPLICATE_USERNAME' error: "Duplicate Username.The username already exists in this or another…
srj737
  • 53
  • 4
1
vote
0 answers

Pull all reports filtering by a certain field in Salesforce

Is there a way to pull all active reports in Salesforce that filter by a certain field? I tried using a rest API in workbench "/services/data/v50.0/analytics/reports", but it still seems like I have to manually step into the describe URL for each…
1
vote
0 answers

WHERE Clause for SOQL Query for a date and a case origin type in Salesforce

my objective is to pull a list of cases within Salesforce Service Cloud using SOQL that have happened within this year and are specifically email-to-case. If I try this: SELECT CaseNumber, CreatedDate, ClosedDate FROM Case WHERE CreatedDate >…
1
vote
0 answers

Passing a String[] or List to Salesforce Bulk Job for EventWhoIds in Ruby

I'm trying to create a job in Salesforce using the salesforce_bulk_api gem that adds EventWhoIds to an Event. I have been able to successfully do this using the restforce gem by simply passing in an array of Ids like this: sf_client.upsert!('Event',…
camillavk
  • 521
  • 5
  • 20
1
vote
1 answer

EXCEPT clause in SOQL

I would appreciate a little help. How do I write EXCEPT clause in Salesforce SQL? I would like to have query which excludes rows based on a few conditions from the same database. Like this: SELECT Email_address FROM Database_1 EXCEPT SELECT…
Amberjack
  • 45
  • 5
1
vote
1 answer

How To Amend This SOQL to get All records for today After 6am

Is there a way I can customize this SOQL query to include all records after 6am from Today? SELECT Case__c, Level_1__c, Level_2__c,Level_3__c FROM Case_Type__c WHERE createddate = today GROUP BY Case__c,Level_1__c,…
1
vote
1 answer

Is there SOQL function to convert Date to Unix timestamp in Salesforce SOQL or SOSL?

Hi Salesforce developers, I am exporting standard Contact fields with Salesforce SOQL. I need to import it to other tool but I need to convert LastModifiedDate, which is ISO datetime string, into Unix timestamp seconds from 1/1/1970. SELECT…
mizi_sk
  • 1,007
  • 7
  • 33
1
vote
1 answer

Query on subquery containing JOINS in Salesforce SQL (SOQL)

SELECT Email_address, COUNT(Order_date) FROM (SELECT cust.Email_address, COUNT(ol.Variant_name), ord.Order_date FROM DMW_Order_Line_v3 ol JOIN DMW_Order_v3 ord ON ol.Unique_transaction_identifier =…
Amberjack
  • 45
  • 5
1
vote
1 answer

Combine two Salesforce SOQL Query

I am using two SOQL query in Salesforce. First Query: Select Id, FirstName, LastName from User where Id='00000ADFEDSFSRTGDR' Second Query: Select IsFrozen from UserLogin where UserId='00000ADFEDSFSRTGDR' Can we combine these two query into a single…
user3441151
  • 1,880
  • 6
  • 35
  • 79
1
vote
2 answers

How do you parse a SOQL AggregateResult column with no value?

Let's say you run a SOQL aggregate query that looks like this: select OwnerId, sum(ExpectedRevenue)val from Opportunity GROUP BY ROLLUP(OwnerId) For whatever reason, there are no Opportunities with ExpectedRevenue fields populated. You get a table…
Ryan Elkins
  • 5,731
  • 13
  • 41
  • 67
1
vote
1 answer

Second Order SOQL SOSL Injection SFDC

I am getting error in Checkmarx. Method abortJob at line 209 of XXX/classes/Monitoring.cls gets user input from the select element. This element’s value then flows through the code without being properly sanitized or validated, and is eventually…
1
vote
1 answer

How can I filter a SOQL query in a Python script after a specific datetime?

I'm trying to select all records from the OPPORTUNITY object that are greater than a variable DateTime. However, I can't figure out how. This is in a Python script using the simple_salesforce package. I believe the issue is either that I am missing…
Lee Werner
  • 167
  • 7
1
vote
1 answer

SOQL querying url addresses

I'm struggling to get the right SOQL query in a way that I can search and filter by URL addresses, through the API. We have a custom field Crunchbase_URL__c, which can be both written by my application (usign the REST API), or filled in manually by…
1
vote
1 answer

Salesforce SOQL return all partners of single account

I am trying to find all the account that have the same partner. I am new to SOQL and I cannot do a join so I am at a loss. Here is the closest I have gotten: Select Name, Site, Status__c FROM Account WHERE Account.Id = Partner.AccountToId AND…
Adunahay
  • 1,551
  • 1
  • 13
  • 20
1
vote
0 answers

Salesforce: Queries yield different record counts in despite of same condition on the same object

first query, record count = 10k: SELECT Id FROM Account WHERE LastModifiedDate >=2020-04-18T01:03:21Z AND LastModifiedDate < 2020-04-19T01:03:21Z second query, record count > 10k: SELECT Id "and several other fields" FROM Account WHERE…
notAnExpert
  • 123
  • 1
  • 5
  • 15