check condition hours after record create
# ask-stanley-ai
p
check condition hours after record create
c
AI generated answer (using internal Slack threads):
In NetSuite, you can use SuiteScript or workflows to check conditions hours after a record is created. For SuiteScript, you can use a Scheduled Script that runs every hour and checks the creation date of the records. If the record was created more than 3 hours ago and the checkbox is still ticked, you can untick it. Here is a pseudo-code example:
Copy code
javascript
var searchResult = search.create({...}); // create a search for the records
searchResult.run().each(function(result){
    var creationDate = result.getValue({name: 'created'});
    var checkbox = result.getValue({name: 'checkbox'});
    if(checkbox && (new Date() - new Date(creationDate)) > 3*60*60*1000){ // if checkbox is ticked and more than 3 hours passed since creation
        record.submitFields({
            type: 'customrecord_my_record',
            id: result.id,
            values: {
                'custrecord_checkbox': false
            }
        });
    }
    return true;
});
For workflows, you can use a scheduled workflow that runs every hour and checks the creation date of the records. If the record was created more than 3 hours ago and the checkbox is still ticked, you can untick it. However, you might face some limitations with workflows, as they can't be triggered on a schedule. For the second part of your question, you can use a saved search to bring the records created before a specific time. You can use a formula in the criteria to calculate the hours since the record was created. For example,
({now}-{datecreated})*24
will give you a decimal number of hours since the record was created. You can then filter the results based on this number. ****** 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.787731111
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.78239876
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.780907512
Please provide your feedback on this answer.