formula in saved search to pull the date when a fi...
# ask-stanley-ai
s
formula in saved search to pull the date when a field value changes
c
AI generated answer (using internal Slack threads):
To pull the date when a field value changes in a saved search, you can't directly do this with a formula in a saved search. Saved searches in NetSuite do not have the ability to track changes over time or compare values from different time periods. However, you can use a workaround by creating a custom field that stores the previous value of the field you're interested in. Then, you can create a User Event Script that updates this custom field whenever the original field changes. Here's a basic example of how the User Event Script might look:
Copy code
javascript
function beforeSubmit(type){
    if (type == 'edit'){
        var newRecord = nlapiGetNewRecord();
        var oldRecord = nlapiGetOldRecord();
        var newValue = newRecord.getFieldValue('custrecord_my_field');
        var oldValue = oldRecord.getFieldValue('custrecord_my_field');
        if (newValue != oldValue){
            newRecord.setFieldValue('custrecord_previous_value', oldValue);
            newRecord.setFieldValue('custrecord_change_date', nlapiDateToString(new Date()));
        }
    }
}
In this script, 'custrecord_my_field' is the field you're interested in, 'custrecord_previous_value' is the custom field that stores the previous value, and 'custrecord_change_date' is the custom field that stores the date of the change. Then, in your saved search, you can add 'custrecord_change_date' as a result column to see the date when the field value changed. ****** 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.838051319
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.835796654
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.830519557
Please provide your feedback on this answer.