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
DeekDeek 

Clone Account Owner Field in Account object

Hi Moderators,

 

I need to create a new field in Account object which is identical to Owner field (Field Label:Account Owner) of data type [Lookup(User)] which is a standard field in Account?

 

Could you please help me on how to achieve this?

Best Answer chosen by Admin (Salesforce Developers) 
DeekDeek

Thanks Utsav for all your help. Its working fine now with your code.

All Answers

imutsavimutsav

If I understand correctly then its simple , you should create a new lookup field and associate it to the User Object. If you want to populate it with the same value of the the owner(standard) field then you need to write a workflow rule on Account where ownerId!=NULL (created, and any time it’s edited to subsequently meet criteria). Copy the value of ownerId field to this new field. Is this what you want to achieve. If not then let us know your use case as well.

 

Thanks

Utsav

 

[Do mark this answer as solution if it works for you and give a kudos.]

DeekDeek

Hi Utsav,

 

The current Owner field in Accounts has some existing business rules which I dont want to disturb. Thats the reason I want a cloned field of "Owner" which will be used for other purpose. The values in this field will be same as is the current standard field.i.e showing up the users list. 

imutsavimutsav
Then I suppose you would be able to use my above mentioned answer.

Create a User lookup field on Account Object and then write a workflow rule to copy the Owner field value to new Owner Field.

You should be able to create a formula field to get the value or the name of the Owner.

Thanks
Utsav

[Do mark this answer as solution if it works for you and give a kudos.]
DeekDeek

Hi Utsav,

 

I have created the lookup field to user in Account object.

 

Could you please eleborate the steps on the creation of WF rule and then create a formula field to get the value or the name of the Owner.

imutsavimutsav
now write a trigger.

trigger trgUpdateAccountOwner on Account(before Insert,before Update) {
List<Account> accountLists = new List<Account>();
for(Account a: Trigger.new) {
a.newOwnerId = a.ownerId;
accountLists.add(a);
}

}

Thanks
Utsav

[Do mark this answer as solution if it works for you and give a kudos.]
DeekDeek

Thanks Utsav for all your help. Its working fine now with your code.

This was selected as the best answer
imutsavimutsav
Good to know that Dpat, anyways you marked your answer as solution instead of mine.

Thanks
Utsav

[Do mark this answer as solution if it works for you and give a kudos.]
DeekDeek

Thanks Utsav.

DeekDeek
Hi Utsav,



One quick reply please,



In Events object there is a customized pick list field called as "YOR
Status" which has values planned, completed, cancelled and system close
respectively.



My requirement is "YOR status" cannot be set to "Completed" if the
start date of the Event is greater than today.



Please help me out to achieve this.


Notice



This email and any attachments are strictly confidential and subject to copyright. They may
contain privileged information. If you are not the intended recipient please delete the message
and notify the sender. You should not read, copy, use, change, alter or disclose this email or
its attachments without authorisation. The company and any related or associated companies do
not accept any liability in connection with this email and any attachments including in connection
with computer viruses, data corruption, delay, interruption, unauthorised access or unauthorised
amendment. Any views expressed in this email and any attachments do not necessarily reflect the
views of the company or the views of any of our related or associated companies.
imutsavimutsav
You can achieve this by writing a Validation Rule or Trigger on Activity.

Use formula AND, it may look something like below
AND(Yor status='xyz', startdatetime=TODAY)

Thanks
Utsav

[Do mark this answer as solution if it works for you and give a kudos.]