how to build a case statement for expensereport st...
# ask-stanley-ai
v
how to build a case statement for expensereport status as rejected
c
AI generated answer (using internal Slack threads):
To build a case statement for the ExpenseReport status as 'Rejected', you would need to use SuiteScript or a workflow, as there is no direct setting for "reject". In SuiteScript, you can use the
record.submitFields
method to update the approval status field of the ExpenseReport record to 'Rejected'. Here is a sample code snippet:
Copy code
javascript
var recordId = record.submitFields({
    type: record.Type.EXPENSE_REPORT,
    id: 'your_expense_report_id',
    values: {
        'approvalstatus': '2' // 2 is typically the internal id for 'Rejected'
    },
    options: {
        enableSourcing: false,
        ignoreMandatoryFields : true
    }
});
Please note that the internal id for 'Rejected' might be different in your account, so you need to check that. For the case statement in a saved search, you can use a formula field with a case statement. However, NetSuite does not support a direct comparison to the current user in a case statement. You would need to compare the user's internal id to the sales rep's internal id. Here is a sample formula:
Copy code
sql
CASE WHEN {salesrep.id} = {user.id} THEN 1 ELSE 0 END
This formula will return 1 if the sales rep is the current user, and 0 otherwise. ****** 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.788296
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.776515126
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.765588
Please provide your feedback on this answer.