New answers tagged

1

Every object will have createdby and lastmodifiedby field. Those fields basically refers the User object. If you want to get any information related to them from User object, You can refer it by adding the fields from User object in the report layout. Refer this document:- Design the Field Layout for Reports Created From Your Custom Report Type Steps:- ...


1

As the Owner field can be a polymorphic field, you can only access those fields which are common across both objects. In such cases, you can use TYPEOF in your SOQL query and select the fields based on the Owner type. SELECT [fieldList,] [TYPEOF typeOfField {WHEN whenObjectType THEN whenFieldList}[...] [ELSE elseFieldList] ...


1

I think the problem here is that User.Owner is a polymorphic field. That is it can reference either a User object or a Group object. Personally, I just do another query on User via the OwnerId field once I've checked that this Id a User object not a group. I'm interested in finding out if there's a better way of handling this. Why does Owner.Phone work ...


2

Your last 2 debug statements return null because at this moment, your communityUser only has the values that you defined a few lines above. If you query that user right after insert with all these fields, then you should have all the info that you need: insert communityUser; communityUser = [SELECT Id, ContactId, Contact.AccountId, AccountId FROM User ...


0

The second-to-last statement prints null, because you can't traverse relationships that way. You can only access the Contact relationship from the User if you use a relationship query. The last statement prints null because you haven't set AccountId on the User.


Top 50 recent answers are included