function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
kfm2012kfm2012 

Add Account Owner to Case screen

We're starting to use Cases to track our interactions with our clients and we rely heavily on the Account Owner field.  On the Cases screen we need to add a field for the Account Owner of the Account that is selected.  We also need the Account Owner to create views/queue's of all cases for each sales person(account owner).  It sounds like this can be done by creating a custom formula field but we can't figure out how to define the formula.  In our custom field, we have Account.Owner which shows the salesforce ID but we're looking for the owner name.

 

Any guidance would be appreciated.  thx

Best Answer chosen by Admin (Salesforce Developers) 
champvimalchampvimal

I meant to say whatever field name you have given for Owner__r.LastName

 

I think you have given Owner_Copy__c as API Name for Owner. So put Owner_Copy__r.LastName.

All Answers

champvimalchampvimal

Frequently asked Use-Case.

 

But unfortunately, Salesforce Out-of-Box does not provide Owner's Name as option while traversing fields during creation of formula.

 

Please vote here to have it available in Salesforce asap.

 

http://success.salesforce.com/ideaview?id=08730000000BrqaAAC

 

Also, there is a workaround on this with simple creation of a formula field and a trigger as shown here. This will resolve your issues for timebeing.

 

http://www.michaelforce.org/recipeView?id=a0G30000006aQgCEAU

 

 

Thanks,

 

Vimal

 

 

kfm2012kfm2012

Vimal:  thanks for the reply, this is very helpful.  So I've created the owner_copy_c lookup field and created the trigger on Case.  When I create a new case, the trigger is populating the owner_copy_c with my name as I am the case owner.  But what I'm trying to do is populate the field with the owner of the Account that was selected on the case screen.  So even if I own the case, I want to be able to display the Owner of the account that the case is referring to.  How do I take this one step further to accomodate this?  We need to be able to create views, reports etc. that show all cases related to the salespeople that are the owners of the accounts.  thx again!

champvimalchampvimal

Hi,

 

As mentioned in the blog, now since you have "Account Owner (Copy) lookup to User available in Formula's "Insert field" window, you can create a formula with data type as text and in Insert Field panel perform :

 

Case > Account Owner (Copy) > Any field you want to access of the Owner (First Name, Last Name, Division, Department, etc).

 

 

Thanks,

 

Vimal

 

 

kfm2012kfm2012

Vimal:

thanks again.  I think I'm really close but I'm missing something.  I'm still getting myself as the owner but I'm looking for the name of the Owner of the Account that was associated with the Case.  Here's what I've done:

 

1) I created Owner_Copy_C which is custom lookup field Related To: User

2) here's my Trigger

trigger ownerCopy on Case (before Insert, before Update) 
{
// handle arbitrary number of opps 
for(Case x : Trigger.New)

// check that owner is a user (not a queue) 
if( ((String)x.OwnerId).substring(0,3) == '005' )

x.Owner_Copy__c = x.OwnerId;
}
else
{
// in case of Queue we clear out our copy field
x.Owner_Copy__c = null; 
}
}
}

3) Then I created a custom formula field RM with Formula of Owner_Copy_r.Username

 

It seems to be picking up myself as Owner of the Case but I'm looking for Owner of the Account that was associated to the case.   Any more guidance would be really appreciated.  thx again.

 

kfm2012kfm2012

I still need help getting to the Case Account Owner information.  I'm close....

 

1) On the Cases Screen, I created Owner_Copy_C which is custom lookup field Related To: User

2) I also have a formula field called Rel_Mgr with formula Rel_Mgr (Text) = Account.OwnerId

3) Rel_Mgr_c will show the correct ID of the Account Owner

4) I have a very simple trigger:

 

trigger ownerCopy on Case (before Insert)
{
Case x = trigger.new[0];
x.Owner_Copy__c = '005E0000000JZXa';
}

 

This trigger will put 005E0000000JZXa in the Owner_Copy_C field and the correct Owner Name will display.  But in the trigger, I need to get the Account.OwnerId and put it in Owner_Copy_c.  I've tried a number of things in the trigger including x.Owner_Copy_c = x.Account.OwnerId but can't get it to work.  I've also tried x.Owner_Copy_c = x.Rel_Mgr_c.  Any help would be great.

 

champvimalchampvimal

x.Owner_Copy__c = x.OwnerId; 

 

Needs to be :

 

x.Owner_Copy__c = x.Account.OwnerId;

 

 

Thanks,

 

Vimal

kfm2012kfm2012

thx.  I am currently using x.Owner_Copy__c = x.Account.OwnerId;

 

I'm trying to keep really simple.  My current trigger is:

 

trigger ownerCopy on Case (before Insert)

{
Case x = trigger.new[0];
x.Owner_Copy__c = x.Account.OwnerId;
x.TEST__c = 'TRIGGER FIRED';
}

 

After I save - the test field shows 'TRIGGER FIRED' but the Owner Copy field is blank.  No errors when I save the trigger or when it runs.  Maybe it's some sort of permissioning issue?  What else can I try?  thx



 

champvimalchampvimal

Let the trigger be as it is. That is : x.Owner_Copy__c = x.Account.OwnerId;

 

Have the formula field "Rel_Mgr__c" with the formula :  Account_Owner_Copy__r.LastName 

 

Try this and see if it populates the Account Owner's Last Name.

 

 

Thanks,

 

Vimal

champvimalchampvimal

And I assume you have placed the formula field "Rel_Mgr__c" on the page layout and visible for the profile you are working with.

 

 

Thanks,

 

Vimal

kfm2012kfm2012

Yes I have the field visible on the page.  If I put Account_Owner_Copy__r.LastName in the formula field I get error field does not exist. 

 

thanks
Kevin

 

champvimalchampvimal

I meant to say whatever field name you have given for Owner__r.LastName

 

I think you have given Owner_Copy__c as API Name for Owner. So put Owner_Copy__r.LastName.

This was selected as the best answer
kfm2012kfm2012

yes, I had tried that also.  I don't get any errors but the Rel Mgr field is also blank after saving. 

 

thx

Kevin

 

kfm2012kfm2012

Ahhh, I think we got it. 

 

My trigger is now:

 

trigger ownerCopy on Case (before Insert)

{
Case x = trigger.new[0];
x.Owner_Copy__c = x.Rel_Mgr__c;
x.TEST__c = 'TRIGGER FIRED 2';
}

 

Rel_Mgr__c is the formula field Account.OwnerID.  I set Owner_Copy__c to this and it seems to be working .  More testing to do but much thx.  I'm obvioiusly a newbie - you've been extremely helpful