Setting a beforeload Item Fulfillment Workflow's S...
# ask-stanley-ai
a
Setting a beforeload Item Fulfillment Workflow's State Field to Line : Location : Location Category on Entry or BeforeLoad, during a Create event trigger, sets the workflow state field to null, or at least it says null when I reference it in the text of a Show Message action later during Before User Submit. I can't do a Sublist Action Group on Before User Submit, and outside a sublist action group, I'm not able to reference the individual Lines to see what their Inventory Location is. So I don't know how to tell if it's coming up null because it's running on a Create event's beforeload or what the reason is.
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems that the issue you're facing is related to the limitations of the Before Load event in the context of a workflow. The Before Load event is not able to reference the individual lines of a sublist, which is why you're unable to see the Inventory Location for each line. In addition, setting the State Field to Line : Location : Location Category during a Create event's Before Load seems to result in a null value. This could be due to the fact that the record is not fully loaded during the Before Load event, and therefore some fields may not be available or may not have been set yet. One possible solution could be to use a combination of SuiteScript and workflows. You could use a User Event Script to capture the Create event and set the State Field. Then, use a workflow with a Sublist Action Group on Before User Submit to reference the individual lines and check their Inventory Location. Here's a sample code for the User Event Script:
Copy code
javascript
/**
 * @NApiVersion 2.x
 * @NScriptType UserEventScript
 * @NModuleScope SameAccount
 */
define(['N/record'], function(record) {
    function beforeLoad(context) {
        if (context.type === context.UserEventType.CREATE) {
            var itemFulfillment = context.newRecord;
            
            // Set the State Field
            itemFulfillment.setValue({
                fieldId: 'custbody_state_field', // Replace with your State Field ID
                value: 'Line : Location : Location Category' // Replace with your desired value
            });
        }
    }

    return {
        beforeLoad: beforeLoad
    };
});
Please note that this is a general solution and may need to be adjusted to fit your specific business logic and 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.855981827
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.841583729
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.84155
Please provide your feedback on this answer.