In my NetSuite I have a custom record Name: Sampl...
# ask-stanley-ai
s
In my NetSuite I have a custom record Name: Sample Tracking Form id: customrecord_sample_tracking and on that record I have a field: Description: Sample Request Selector ID: custrecord_sample_tracking_request_id Type: List/Record List/Record: Sample Request (Another custom record, id is customrecordcustomrecord_sample_request) What I want that in the dropdown I only want those option which are not previously selected. means: suppose I have 3 item in Sample Request and 0 item in Sample Tracking Form 1. when creating new sample request for the first time , see three option on the list and choose one and create one entry 2. on creating next entry - there should be two option in the list/dropdown, remove the already selected 3. one on creating next entry - there should be one option in the list/dropdown, remove the already selected ones
c
AI generated answer (using internal Slack threads):
To achieve this, you can use a SuiteScript to dynamically populate the dropdown list. You can create a SuiteScript that runs on the form and populates the dropdown list with the values from the 'Sample Request' custom record. The script should also check the 'Sample Tracking Form' custom record to see which 'Sample Request' values have already been selected, and exclude those from the dropdown list. This can be done by performing a search on the 'Sample Tracking Form' custom record and comparing the results with the 'Sample Request' values. Here is a basic example of how you might do this:
Copy code
javascript
function beforeLoad(type, form, request){
    if(type == 'create'){
        var sampleRequestField = form.getField('custrecord_sample_tracking_request_id');
        var sampleRequestValues = searchSampleRequestValues();
        var usedSampleRequestValues = searchUsedSampleRequestValues();
        var availableSampleRequestValues = sampleRequestValues.filter(function(value){
            return usedSampleRequestValues.indexOf(value) == -1;
        });
        availableSampleRequestValues.forEach(function(value){
            sampleRequestField.addSelectOption(value.id, value.name);
        });
    }
}

function searchSampleRequestValues(){
    // Perform a search on the 'Sample Request' custom record to get all values
    // Return an array of objects, each with an 'id' and 'name' property
}

function searchUsedSampleRequestValues(){
    // Perform a search on the 'Sample Tracking Form' custom record to get all used 'Sample Request' values
    // Return an array of ids
}
This script should be deployed as a User Event script on the 'Sample Tracking Form' custom record. The
beforeLoad
function is triggered when the form is loaded, and it populates the 'Sample Request Selector' dropdown list with the available 'Sample Request' values. ****** 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.839421272
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.83902818
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.834273398
Please provide your feedback on this answer.