0

I'm trying to do a table export based on specific criteria, and the only tools I have at my disposal are Data Loader and Workbench.

If I were to do this with SQL I would do:

SELECT 
Id,CreatedById,CreatedDate,IsDeleted,LastActivityDate,LastModifiedById,LastModifiedDate,LastViewedDate,Name,SF__Applicant__c,SF__Job__c,SF__Status__c
FROM SF__Application__c
WHERE (CreatedDate > 2019-04-01T00:00:00.000Z
OR LastModifiedDate > 2019-04-01T00:00:00.000Z)
AND SF__Job__c IN (SELECT Id FROM SF__Job__c WHERE ownerId IN (SELECT Id FROM User WHERE Country IN ('CountryA','CountryB')))

I have looked for other examples/alternatives and I see the use of apex being the frequent suggestion. Something like:

List<SF__Job__c > JobList = [SELECT Id FROM SF__Job__c WHERE ownerId IN (SELECT Id FROM User WHERE Country IN ('CountryA','CountryB'))];

List<SF__Application__c> applist = [SELECT 
Id,CreatedById,CreatedDate,IsDeleted,LastActivityDate,LastModifiedById,LastModifiedDate,LastViewedDate,Name,SF__Applicant__c,SF__Job__c,SF__Status__c
FROM SF__Application__c
WHERE (CreatedDate > 2019-04-01T00:00:00.000Z
OR LastModifiedDate > 2019-04-01T00:00:00.000Z)
AND SF__Job__c IN :JobList];

But as far as I can tell, I have no way to export using this method, like to do with SOQL Query in Workbench, or Export from data loader.

Any help anyone can provide is greatly appreciated!

1 Answer 1

0

I would first try to simply filter on Owner.Country:

SELECT ...
FROM SF_Application__c

WHERE SF__Job_Id__c IN (SELECT Id FROM SF__Job__c WHERE Owner.Country IN (...)

Failing that, the go to solution for limitations in SOQL is to add a formula. It should be relatively straightforward to introduce an Owner_Country__c field and filter on that instead.

5
  • Thank you for the quick response! So I have tried that before, but owner.country for some reason isn't valid from this table, despite being valid from others. I get No such column 'Country' on entity Commented Jun 14, 2021 at 16:13
  • Yeah then the canonical approach would be to write it into a formula.
    – Adrian Larson
    Commented Jun 14, 2021 at 16:14
  • Which unfortunately is not something I have the ability to do in this situation :( Commented Jun 14, 2021 at 16:15
  • Why are you not able to add a formula?
    – Adrian Larson
    Commented Jun 14, 2021 at 16:17
  • Not within my authority to do so, its one of our clients systems. Could possible look at getting one made, but for the purpose of this one off data export my best solution may just be to dump both tables to csv and hand the data in a SQL server or excel. Commented Jun 14, 2021 at 16:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .