You need to sign in to do that
Don't have an account?
Ab
Prepopulate a lookup on the creation of account
Hello,
object: Account
custfield__1 (Lookup to Obj1)
Obj1
Name (Standard field: mandatory)
Usecase:
when account is created, the Name is autofilled or updated with value "XYZ" and make sure with a SOQL that the record is well present.
How could i implement it with Trigger ?
thanks you for suggestion.
object: Account
custfield__1 (Lookup to Obj1)
Obj1
Name (Standard field: mandatory)
Usecase:
when account is created, the Name is autofilled or updated with value "XYZ" and make sure with a SOQL that the record is well present.
How could i implement it with Trigger ?
thanks you for suggestion.
Hi Sandrine,
Do you want the lookup to be populated after the Account is created or when the user clicks on the Create button?
1. If needed after the record is inserted you can use a before trigger to search for the record and populate the id
2. If needed on clicking the Create button, you will have to override the new (create) button with a VF page. Use the action attribute of apex:page to query XYZ record.
If a record is found, then redirect to the standard record creation page by url-hacking the parameters.
https://na1.salesforce.com/001/e?retURL=%2F001%2Fo&CF00N9000000F4tOt_lkid=012900000011ul8&CF00N9000000F4tOt=XYZ&ent=Account
Steps :
Note :
1. In order to auto-populate any field that field must be on the page layout
2. Inorder to find the field id go to Setup-Customize-Account-Fieldname // in the url you will find the id
OR
2. Go to the objects creat/edit page, right click on field and select Inspect you will see such a snippet
Thanks
Vivian
All Answers
Hi Sandrine,
Do you want the lookup to be populated after the Account is created or when the user clicks on the Create button?
1. If needed after the record is inserted you can use a before trigger to search for the record and populate the id
2. If needed on clicking the Create button, you will have to override the new (create) button with a VF page. Use the action attribute of apex:page to query XYZ record.
If a record is found, then redirect to the standard record creation page by url-hacking the parameters.
https://na1.salesforce.com/001/e?retURL=%2F001%2Fo&CF00N9000000F4tOt_lkid=012900000011ul8&CF00N9000000F4tOt=XYZ&ent=Account
Steps :
Note :
1. In order to auto-populate any field that field must be on the page layout
2. Inorder to find the field id go to Setup-Customize-Account-Fieldname // in the url you will find the id
OR
2. Go to the objects creat/edit page, right click on field and select Inspect you will see such a snippet
Thanks
Vivian
As requirement is not genric and not clear but you can try below code.
Thanks
Lokesh