formula in saved search that pulls the date when t...
# ask-stanley-ai
s
formula in saved search that pulls the date when the status field changes old value to new value
c
AI generated answer (using internal Slack threads):
To pull the date when the status field changes from an old value to a new value in a saved search, you would typically need to use a system notes field. However, NetSuite does not directly support this functionality in saved searches. The system notes field in NetSuite keeps track of all changes made to a record, including the old value, new value, and the date/time of the change. But, unfortunately, you can't directly reference these fields in a saved search formula. A workaround could be to create a custom field that gets updated via a SuiteScript each time the status field changes. This custom field would store the date of the change. Then, you can reference this custom field in your saved search. Here is a pseudo-code example of how the SuiteScript might look:
Copy code
javascript
function beforeSubmit(scriptContext) {
    if (scriptContext.type !== scriptContext.UserEventType.CREATE) {
        var oldRecord = scriptContext.oldRecord;
        var newRecord = scriptContext.newRecord;
        var oldStatus = oldRecord.getValue({fieldId: 'status'});
        var newStatus = newRecord.getValue({fieldId: 'status'});
        if (oldStatus !== newStatus) {
            newRecord.setValue({
                fieldId: 'custentity_status_change_date',
                value: new Date()
            });
        }
    }
}
Remember to replace 'status' and 'custentity_status_change_date' with your actual field IDs. ****** 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.823145092
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.821566
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.816558361
Please provide your feedback on this answer.