You need to sign in to do that
Don't have an account?
Auto populate a lookup field in custom object with current user
Hello - I have tried few solutions ( trigger, process builder, lookup helper) based on what I have found online but no luck so far :/, so any help is appreciated.
We have a custom object to enter Incidents: c4g_Incident_Report__c
This object has a lookup field "Reporting Staff" that looks up in the "user" object: c4g_Reporting_Staff__c
Looking for a solution that will auto-populate, before insert, the lookup "Reporting Staff" field with the name of the current user creating the entry.


We have a custom object to enter Incidents: c4g_Incident_Report__c
This object has a lookup field "Reporting Staff" that looks up in the "user" object: c4g_Reporting_Staff__c
Looking for a solution that will auto-populate, before insert, the lookup "Reporting Staff" field with the name of the current user creating the entry.
Hi Renier,
If you are trying to achieve this with the standard "New" page of salesforce then it is not possible to auto populate the value in a field.
This can be achieved if you create your own Custom VF page and then override this custom VF page on the New button of your object.
Please let me know if you need more information on this.
Thanks,
Abhishek Bansal
Renier
There is only one way by which you can acheive this requirement. You have to follow the below mentioned steps in order to get what you want :
1. Create a new custom VF page with standard controller as your currenct object i.e. "c4g_Incident_Report__c".
2. In the extension of this VF page populate the value in the field "c4g_Reporting_Staff__c".
3. On your VF page show input fields as per your requirement.
4. Now override this VF page on the "New" button of your "c4g_Incident_Report__c" object.
Yur VF page and controller class will look something like below :
VF page :
Controller Class :
In order to override the standard New button with your VF page please foolow the below steps :
1. Click on Setup
2. In search box at Left side enter "Objects".
3. Click on Objects.
4. Click on "c4g_Incident_Report__c"
5. Scroll down to Custom Buttons and Links section
6. Click on "Edit" link in front of New Button
7. In the "Override With" section Select "Visualforce Page" radio button
8. In the drop down of Visualforce page select the page that you have created now.
Please let me know if you still need any help or information on this.
Thanks,
Abhishek Bansal
Are you creating "New" incidents from the related list(c4g_Incident_Report__c) "New" button .
IF it is yes then you can remove Standard "New" button and replace with custom button "New" and do URL hacking.Create a custom button as described below:
https://success.salesforce.com/answers?id=90630000000hOx0AAE
Thanks & Regards,
Dinesh
Renier