In this guide, we will explain how to auto-prefill a Salesforce Lookup with the User attribute.
If the user has an attribute, the Lookup will automatically pre-fill with the Record ID. If not, then have the Lookup usually.
Please check out the below guide to edit user details and add custom attributes:
Add custom attributes for the User:
Please add a record id of a Salesforce record in the custom attributes option for the user.
Auto prefill Salesforce Lookup with the User attribute (record_id):
Drag and drop a Salesforce Lookup and a JavaScript field.
Click the pencil icon of the Salesforce lookup field, then select the Object and the Display Additional fields. Save the changes.
Click the pencil icon of the JavaScript field, then paste the code and save the changes. Please change the field id as per your form.
Please use the below code:
if ( window.formyoula.user && window.formyoula.user.Formyoula_User_Attributes && window.formyoula.user.Formyoula_User_Attributes.record_id) {
// lookup id
window.formyoula.form_fields['6ae1-3de8-8650'].set({"value": window.formyoula.user.Formyoula_User_Attributes.record_id})
}
Try the form. The form will auto-prefill the Salesforce Lookup with the User attribute (record_id).
For any questions, please contact us - [email protected] or the Formyoula in-app chat 🙂