You need to sign in to do that
Don't have an account?
faceroy123
Case owner details via apex
Hi,
I'm trying to pull through some details relating to a case owner.
I have workflows that fire if a case is owned by a queue that work fine.
I now just want to fire back a text field from the related user (a custom relationship field) but it doesn't seem to populate:
There are no errors on the code it just doesn't populate even though the field is populated on the user record.
thanks
trigger region on case (before Insert, before Update) { for(case x : Trigger.New){ if(x.User__c == null) { x.case_owner_region__c = x.RCCM_region__c ;} else if(x.User__c!= null) { x.case_owner_region__c = x.user__r.region__c ; } } }
hi faceroy123,
With trigger.new look-up fields can't be accessed. simply returns null value even if we try to acces the fields.
So, you would need to query the fields and Iterate through it.
Thanks very much.
This is all new to me.
So do I put the name of the field in that section? What about the final section?
Hi,
try using following code, Instead of using Trigger.new list directly, use query.
No errors this time but the fields do not populate as I would expect.
If the case is owned by a user a custom lookup field (User__c)will populate based on another trigger I have that works fine. This field is a lookup to the user. If this is populated I want to lookup on that user to find a region field (user__r.region__c) and populate it in (case_owner_region__c).
If the case is owned by a queue, the custom lookup to user is left blank and a workflow rule fires to populate a case field with a region.(RCCM_Region__c). In this instance I want this populated in the field (Case_owner__region__c).
I hope this is clear. Apologies but I'm still learning :-)