how can i set a field value as the system notes cr...
# ask-stanley-ai
a
how can i set a field value as the system notes created by field for when a journal entry is approved?
c
AI generated answer (using internal Slack threads):
To set a field value as the system notes created by field for when a journal entry is approved, you can use a combination of SuiteScript and Saved Search. In SuiteScript, you can use a User Event script with a beforeSubmit function to check for the CREATE event and set the approval field to 'T' (true). Here is a simplified example:
Copy code
javascript
function beforeSubmit(context) {
    if (context.type === context.UserEventType.CREATE) {
        context.newRecord.setValue('approvalField', true);
    }
}
For the Saved Search, you can use a combination of criteria and results to get a full GL population without making duplicate lines. You can use a systemnotes join and look for the change from 'Pending Approval' to 'Approved for Posting'. The 'set by' field would be the person who approved it at the final stage. Here are some formulas that you can use in your Saved Search: 1st formula:
Copy code
sql
CASE WHEN {systemnotes.field} = 'Document Status' AND {systemnotes.newvalue} = 'Approved for Posting' THEN TO_CHAR({systemnotes.date}, 'MM/DD/YYYY HH:MI:SS') END
2nd formula:
Copy code
sql
CASE WHEN {systemnotes.field} = 'Document Status' AND {systemnotes.newvalue} = 'Approved for Posting' THEN TO_CHAR({systemnotes.name}) END
3rd formula:
Copy code
sql
TO_CHAR({systemnotes.date}, 'MM/DD/YYYY HH:MI:SS')
4th formula:
Copy code
sql
max(to_char(substr({systemnotes.name},1,4000)))keep(dense_rank last order by{systemnotes.date})
These formulas will help you to pull out the most recent "Set By" field through system notes. ****** 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.833613157
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.830160499
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.824554
Please provide your feedback on this answer.
a
how can i do it via a workflow?