I am trying to trigger my automation (using a UE s...
# ask-stanley-ai
s
I am trying to trigger my automation (using a UE script or Workflow) on the creation of Purchase Order (PO), which were created from a Purchase Requisition (PR), using NetSuite's standard bulk Purchase Order creation page. Requirement: I need to make sure that the custom form selected on PO is based on the custom form selected on PR. Also, need to make sure that some custom transaction line fields on PO are also populated according to values in PR (when incorrect form is selected, these values are not populated correctly). Problem: Now the issue is that my automation(s) are not triggering at all when the PO is created from PR. In system notes of PO the context is "Bulk Processing" BUT in the Script Deployment/Workflow -> Context Filtering, there is no such context as Bulk Processing. Am I missing something or do I need to take a different approach.
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems that the issue you're facing is due to the context in which the Purchase Order (PO) is being created. When a PO is created from a Purchase Requisition (PR) using NetSuite's standard bulk Purchase Order creation page, the context is "Bulk Processing". However, this context is not available in the Script Deployment/Workflow -> Context Filtering, which is why your automation is not triggering. One possible solution could be to use a Scheduled Script or Map/Reduce Script instead of a User Event (UE) script or Workflow. These types of scripts are designed to handle bulk processing and do not rely on the context in which the records are created. In your Scheduled Script or Map/Reduce Script, you can load each newly created PO, check if it was created from a PR, and then perform your necessary custom form selection and field population. Here is a basic example of how you might structure this in a Scheduled Script:
Copy code
javascript
define(['N/search', 'N/record'], function(search, record) {
    function execute(context) {
        // Create a search to find all POs created from PRs
        var poSearch = search.create({
            type: search.Type.PURCHASE_ORDER,
            filters: [
                // Add your filters here
            ],
            columns: [
                // Add your columns here
            ]
        });

        poSearch.run().each(function(result) {
            // Load the PO
            var po = record.load({
                type: record.Type.PURCHASE_ORDER,
                id: result.id
            });

            // Check if the PO was created from a PR
            var createdFrom = po.getValue('createdfrom');
            if (createdFrom) {
                // Perform your custom form selection and field population here
            }

            return true; // Continue to the next result
        });
    }

    return {
        execute: execute
    };
});
Please replace the comments with your actual logic. This is just a basic example and may need to be adjusted based on your specific requirements. ****** 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.846435666
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.840515256
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.831543
Please provide your feedback on this answer.