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
Kiran MarketingKiran Marketing 

Formula Field / Lookup for Current User

I am prepopulating certain values in a standard page and i have created a lookup / formula field on user object where the present user id or account owner id should prepopulated. Not sure for some reason when i am creating a lookup or formula field on user its not getting a hyperlink its giving values but not hyperlinks like owner id when u click your redirected to the user record. I need this as i need to pull reports based on it.

Created formula field (Text) also tried with look up and with User.Id and, user name. Below line shows values but not as hyperlinks to the User Record.

={$User.FirstName + " "+ " " +$User.LastName}

={$User.Id}

Any help would be higly appreciated.
Arunkumar RArunkumar R
Hi Kiran,

Please try the following in formula,
 
HYPERLINK('/'+ $User.Id ,  $User.FirstName + ' ' +$User.LastName , "_self")

Third parameter is "target" optional, you can set the below values,

The target parameter is optional. If you do not specify a target, the link opens in a new browser window. Some common target parameters are:
_blank
Displays link in a new unnamed window.
_self
Displays link in the same frame or window as the element that refers to it.
_parent
Displays link in the immediate frameset parent of the current frame. This value is the same as _self if the current frame has no parent.
_top
Displays link in the full original window, canceling any other frames. This value is the same as _self if the current frame has no parent.
Kiran MarketingKiran Marketing
Arun

Thanks for quick reply. I tried that one but the problem is lets say i have two Kiran Rao's. How would this get the current user (Kiran Roa not sure which one of the two)and can this be also modified to get the account owner.

Was i clear with the query. Or should i eloborate on it.

Thanks and regards.
Arunkumar RArunkumar R
Hi Krian, 

By default, $User will return current user details alone. There is no conflict will occur. 

Can you elobarate your problem?
Kiran MarketingKiran Marketing
Arun

I had to create two custom fields on User object.

1) One field should populated with current user or account owner id. So i created a formula field and captured current user now sure how to capture account owner id yet.

2) I have attahed a sceen shot below which is actually fine but i dont want it to show Partner User and Customer Portal User at all i just need one box there where i can lookup for standard users instead of having 2 boxes in UI (first drop box need to be eliminated).

User-added image

Thanks and truly appreciate your help!
Arunkumar RArunkumar R
Hi Krishna,

Hope you are trying to get Account Owner Id of the current user. This field value populated if the user either partner/customer portal user.

1. Inorder to get this details use formula like below,
HYPERLINK('/'+ Contact.Account.Owner.ID,  Contact.Account.Owner.FirstName + ' ' +Contact.Account.Owner.LastName , "_self")

2. Hope this can't be removed.
Kiran MarketingKiran Marketing
Arun

I got that pat covered, however my below code is completely wrong i guess as once i prepopulate the values and when i choose a user in the reffered lookup field mentioned in above post. After clicking Save button the lead should be saved and its lead owner should be the one selected in reffered lookup field. Currently when i click it saves current user as Lead Owner.

Hence i wrote a trigger for this before insert on Lead but seems to be completely wrong. RecordType id = 01228000000YtCD
Tried with trigger.new too but its failing.
 
public class LeadTriggerHelperClass {
public static void isBeforeInsert(Map<Id,Lead> Lead)
{Lead Lea = New Lead();
 
    If(Lea.RecordTypeid == '01228000000YtCD')
    {
      Lea.OwnerId = Lea.Reffered_To__c;
    	Insert Lea;
    }
}
}

 
Joshua HricJoshua Hric
Kiran,
You need to use the 18 digit record type id. You can pull it with Data Loader, or use "https://webcache.googleusercontent.com/search?q=cache:MJt6Jm75lNUJ:https://www.adminbooster.com/tool/15to18+&cd=1&hl=en&ct=clnk&gl=ph" to quickly convert a few 15 digit record types to 18 digit record types.