2

I'm having peculiar trouble with the following query:

SELECT Id, Name, RecordType.Name FROM ts2__Placement__c WHERE RecordTypeId IN (SELECT Id FROM RecordType WHERE Name = 'Contract' AND SObjectType = 'ts2__Placement__c')

For some reason, this doesn't return any records although I've checked and know they exist such as below:

enter image description here

If I change the query to look for 'Temp' record types, they pull through. I noticed that although on records it says 'Contract', but in the object itself it says Contractor as below.

enter image description here

Even when I change the query to look for "Contractor", it still pulls nothing through.

On a list view, I see that it pulls through record types with the name "Contract" and when I search for record types see that "Contract" and "Contractor" are both there although this doesn't appear on the object itself.

enter image description here

I'm confused here but even if I search for records where RecordTypeId = '###' I still get nothing returned.

Am I missing something obvious here?

Thanks for any help.

4
  • 1
    I've suffered at the hands of this as well, I think they are Temp, Perm and Temp-to-Perm ? I know in my code, what I am referring to as Contract I am using 'Temp-to-Perm' as the name. Sep 22, 2015 at 12:37
  • 1
    @PhilHawthorn thanks for your suggestion here. Unfortunately the DeveloperName this isn't the problem. The Contractor RT is a custom RT and is definitely the type we're using with our records.
    – Dan Jones
    Sep 23, 2015 at 8:22
  • 1
    @PhilHawthorn I take that back completely. I'm assuming you use JobScience as well? Either way this was exactly what the problem was. Strange there's nothing in the RecordType to indicate the label? If you write this as an answer I'll be sure to mark it as correct.
    – Dan Jones
    Sep 23, 2015 at 9:14
  • I worked on a project where we had to integrate with JobScience, I recognised the ts2__ namespace. Sep 23, 2015 at 11:52

3 Answers 3

1

I've suffered at the hands of this as well, I think the Record Types Names are Temp, Perm and Temp-to-Perm. I know in my code, what I am referring to as Contract I am using Temp-to-Perm as the name.

0

Change your query to :

SELECT Id, Name, RecordType.Name FROM ts2__Placement__c WHERE RecordTypeId IN (SELECT Id FROM RecordType WHERE DeveloperName = 'Contract' AND SObjectType = 'ts2__Placement__c')

This should work!

5
  • Hi Santanu, thanks for your reply but unfortunately this hasn't worked. It's still not retrieving anything. Curiously, what's the difference between Name and DeveloperName?
    – Dan Jones
    Sep 22, 2015 at 12:18
  • Name is the label of your Record Type and DeveloperName is the API name of your RecordType. Btw, have you tried running your queries in Query Editor of Developer Console? Try playing with them there. Sep 22, 2015 at 12:21
  • Thanks for that. Yeah I've been working via Workbench with these queries and toying with them there but to no avail unfortunately.
    – Dan Jones
    Sep 22, 2015 at 12:29
  • Is it returning any record in workbench? Try to avoid sObjectType in where clause. Sep 22, 2015 at 12:54
  • Unfortunately not. However if I search for Temp with the same object type I do get results.
    – Dan Jones
    Sep 22, 2015 at 13:08
0

Can you confirm following thing

  1. You are running query as Sys Admin, if not you have access to that record type on specific profile.
  2. Run query on recordtype with following query ([SELECT ID,NAME, DeveloperName FROM RECORDTYPE WHERE Sobject='ts2__Placement__c'])
3
  • Thanks Himanshu. Yeah I can confirm I definitely have access to this record type. I've checked this in the Profile settings and I can view Contract records just fine and when I run a query I can find the Record in there.
    – Dan Jones
    Sep 22, 2015 at 14:32
  • are you logged in as sys admin in workbench ?
    – Himanshu
    Sep 22, 2015 at 16:52
  • Yes I am. It's weird because it won't return anything of that particular record type. I've even checked the permissions for my profile and everything is enabled. For some reason though, I can't query anything in that record type.
    – Dan Jones
    Sep 22, 2015 at 16:53

You must log in to answer this question.

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