how do I use soql to get a the value of a calculated field in the activity table for simple_salesforce

382 Views Asked by At

I know this works on the workbench:

SELECT Id,bizible2__BizibleId__c FROM Task

where bizible2__BizibleIid__c is on the activity table. This works too:

SELECT Id,bizible2__BizibleId__c,owner_manager__c FROM Task

but it doesn't work in simple_salesforce. No clue why. So I tried to simulate it because owner_manager__c is a calculated field that equals: Owner:User.Manager.FirstName &" " & Owner:User.Manager.LastName

the owner is a standard relationship for the task table and presumably the activity table. My attempt:

SELECT Id,bizible2__BizibleId__c,Owner.name FROM Task

works, but

SELECT Id,bizible2__BizibleId__c,Owner.Manager.FirstName FROM Task

Didn't work. Manager is a hierarchy thingy. I thought it could be because the owner relationship is user,calendar,something else and not just user, so I tried

SELECT Id,bizible2__BizibleId__c,LastModifiedBy.Manager.FirstName FROM Task

and that didn't work.

2

There are 2 best solutions below

0
On

I figured it out. You have to go to the directory simple_salesforce is in: site-packages\simple_salesforce\api.py. then in the line DEFAULT_API_VERSION = '42.0', change 42.0 to 51.0. That, of course, is a terrible hack, so I asked this question: How do I change the api version of Simple Saleforce

But so far there is no answer other than what I did.

4
On

From what I remember "simple salesforce" uses REST and this API respects field level security. Are you sure you have access to the field? Just because you're sysadmin and bypass stuff in UI doesn't mean your Profile is all right. Workbench might be using SOAP API which is bit old and doesn't enforce the fields (yet).

What does this do for you?

SELECT Id, 
    TYPEOF Owner
    WHEN User THEN Username, Manager.Name
    END
FROM Task

On mutant fields sometimes you need to use polymorphic SOQL to get the fields you want. But still, the formula should work OK.