I have a SOQL query inside my one of trigger

User newOwner = [SELECT ManagerId FROM User WHERE Id=:newCase.OwnerId];

But this query returns ManagerId Null. I checked manually, Manager is defined on owner record.

This soql returns null only when context user is a partner user. As a salesforce user it works fine.

Any idea what is missing?

  • is the owner the one you expect ? maybe there are assignment rules executed after your trigger, and in your trigger scope the Owner is not the one finally set on the Case... – ManSpan Sep 30 '13 at 13:02
  • Yes, OwnerId is coming fine. If I paste that Id in url it takes to me the correct user. Manager is populated there. – doga Sep 30 '13 at 13:06
  • Is it a permissions issue? – Scott Pelak Sep 30 '13 at 15:06
  • @amatorVitae I have also checked that. Permission is given. – doga Sep 30 '13 at 16:47
  • 1
    Field level security? Make sure the partner profile can see the field... – Adrian Larson Sep 30 '13 at 17:16

I solved it by creating a custom formula field on User object ManagerId__c which refers standard ManagerId. Inside my trigger, I used ManagerId__c instead of ManagerId. It works out for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.