I have created a custom record with the parent rec...
# ask-stanley-ai
m
I have created a custom record with the parent record set to the vendor record. when I create custom record from a specific vendor, I want to create a custom field and source the vendor contact email to the custom record which sits on the vendor record under the relationships subtab as the "contacts" sublist.
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems like you are trying to create a custom record that is linked to a vendor record and you want to source the vendor contact email to this custom record. To achieve this, you can follow these steps: 1. Create a custom record and set the parent record to the vendor record. This can be done by checking the 'Record is Parent' checkbox when creating the custom field that holds the vendor record in your custom record. 2. Create a custom field in your custom record to hold the contact email. This field should be of type 'Email'. 3. Set the 'Source List' of this field to 'Contact' and 'Source From' to the email field of the contact record. 4. Set 'Source Filter By' to the field that holds the vendor record in your custom record. This will ensure that only the contacts related to the selected vendor are sourced. Please note that this setup will only source the contact email when the custom record is created from the vendor record. If you want to source the contact email when creating the custom record from other places, you might need to use a SuiteScript to set the contact email field. Here is a sample SuiteScript code that sets the contact email field when the custom record is created:
Copy code
javascript
function beforeSubmit(context) {
    if (context.type === context.UserEventType.CREATE) {
        var newRecord = context.newRecord;
        var vendorId = newRecord.getValue('custrecord_vendor');
        if (vendorId) {
            var contactEmail = search.lookupFields({
                type: search.Type.VENDOR,
                id: vendorId,
                columns: ['email']
            }).email;
            newRecord.setValue('custrecord_contact_email', contactEmail);
        }
    }
}
This script uses the
beforeSubmit
user event to set the contact email field when the custom record is created. It first gets the vendor ID from the new record, then it uses the
search.lookupFields
function to get the email of the vendor, and finally it sets the contact email field with the vendor's email. Please replace 'custrecord_vendor' and 'custrecord_contact_email' with the actual IDs of your custom fields. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.858581543
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.857971251
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.854370117
Please provide your feedback on this answer.