Populate a custom text field with the id of the se...
# ask-stanley-ai
j
Populate a custom text field with the id of the selected option in a dropdown?
c
AI generated answer (using internal Slack threads):
To populate a custom text field with the id of the selected option in a dropdown, you can use SuiteScript. Here's a general idea of how you can do it: 1. Create a client script that will be triggered when the dropdown field is changed. 2. In the fieldChanged function of the client script, get the value of the dropdown field. 3. Set the value of the custom text field with the value obtained from the dropdown field. Here's a sample SuiteScript code:
Copy code
javascript
/**
 * @NApiVersion 2.x
 * @NScriptType ClientScript
 */
define(['N/currentRecord'], function(currentRecord) {
    function fieldChanged(context) {
        if (context.fieldId === 'your_dropdown_field_id') {
            var dropdownValue = context.currentRecord.getValue({
                fieldId: 'your_dropdown_field_id'
            });
            context.currentRecord.setValue({
                fieldId: 'your_custom_text_field_id',
                value: dropdownValue
            });
        }
    }
    return {
        fieldChanged: fieldChanged
    };
});
Please replace 'your_dropdown_field_id' and 'your_custom_text_field_id' with your actual field IDs. Remember to attach this client script to your record type. ****** 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.819934666
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.814745247
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.812290251
Please provide your feedback on this answer.
j
I'm deploying these objects bundled with a suite app. How do I set it up so that when I
SELECT * FROM transaction
using SuiteQL my custom field will get the scriptid or name and not the internal id of the selected record?