how can i prevent sales order creation for commerc...
# ask-stanley-ai
j
how can i prevent sales order creation for commerce upon failed credit card
c
AI generated answer (using internal Slack threads):
****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ****** To prevent sales order creation for commerce upon failed credit card, you can use SuiteScript to add a validation on the Sales Order creation process. You can create a User Event script that triggers before the record is submitted. In this script, you can check if the payment method is a credit card and if the credit card authorization failed. If it did, you can prevent the submission of the Sales Order. Here is a sample code snippet:
Copy code
javascript
function beforeSubmit(type){
    if(type == 'create'){
        var record = nlapiGetNewRecord();
        var paymentMethod = record.getFieldValue('paymentmethod');
        var ccAuthStatus = record.getFieldValue('ccapproved'); //Assuming 'ccapproved' is a custom field that holds the status of credit card authorization
        if(paymentMethod == 'creditcard' && ccAuthStatus == 'failed'){
            throw nlapiCreateError('CC_AUTH_FAILED', 'Credit Card Authorization Failed. Cannot create Sales Order.', true);
        }
    }
}
Please replace 'paymentmethod', 'creditcard', 'ccapproved', and 'failed' with the actual internal ids or values in your account. Remember to deploy this script on the Sales Order record and set the appropriate execution context (e.g., Web Services, User Interface, etc.) based on where the Sales Orders are being created. Please note that this is a basic example and might need to be adjusted based on your specific business requirements and NetSuite setup.
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.793213129
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.791947186
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.791598737
Please provide your feedback on this answer.