i want to create popup message in when the invoice...
# ask-stanley-ai
y
i want to create popup message in when the invoice is pending approval and in view mode
c
AI generated answer (using internal Slack threads):
To create a popup message when the invoice is in 'Pending Approval' status and in view mode, you can use a SuiteScript User Event script. This script will be triggered when the record is being viewed. Here is a sample code snippet:
Copy code
javascript
/**
 * @NApiVersion 2.x
 * @NScriptType UserEventScript
 */
define(['N/ui/message'],
function(message) {
    function beforeLoad(context) {
        if (context.type !== context.UserEventType.VIEW)
            return;
        var record = context.newRecord;
        if (record.type !== record.Type.INVOICE)
            return;
        var approvalStatus = record.getValue('approvalstatus');
        if (approvalStatus == '2') { // 2 is the internal id for Pending Approval
            var myMsg = message.create({
                title: "Pending Approval",
                message: "This invoice is pending approval.",
                type: message.Type.WARNING
            });
            myMsg.show();
        }
    }
    return {
        beforeLoad: beforeLoad
    };
});
This script checks if the record being viewed is an invoice and if its approval status is 'Pending Approval'. If both conditions are met, it shows a warning message. Please note that you need to deploy this script on the Invoice record type. ****** 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.841599464
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.838449121
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.834818482
Please provide your feedback on this answer.