How can I default the department field on transact...
# ask-stanley-ai
j
How can I default the department field on transactions based on the subsidiary set?
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 default the department field on transactions based on the subsidiary set, you can use a workflow or a script. Here are the steps to create a workflow: 1. Navigate to Customization > Workflow > Workflows. 2. Click on 'New Workflow'. 3. Set the 'Record Type' to the transaction type you want to default the department field for. 4. Set the 'Trigger Type' to 'Before Record Load'. 5. In the 'State' section, add a new action of type 'Set Field Value'. 6. In the 'Set Field Value' action, set the 'Field' to 'Department' and the 'Value' to the department you want to default based on the subsidiary. Please note that the department value should be the internal ID of the department record. You can find this by navigating to Lists > Classifications > Departments and clicking 'Edit' on the department you want to default. The internal ID will be in the URL. If you find that workflows are not working for some transactions, you may need to use a script. The script would be a User Event script that sets the department field in the beforeLoad function. The script would be similar to the following:
Copy code
javascript
function beforeLoad(type, form, request){
    if(type == 'create'){
        var subsidiary = nlapiGetFieldValue('subsidiary');
        if(subsidiary == 'your_subsidiary_internal_id'){
            nlapiSetFieldValue('department', 'your_department_internal_id');
        }
    }
}
Replace 'your_subsidiary_internal_id' and 'your_department_internal_id' with the internal IDs of your subsidiary and department, respectively. Please note that the subsidiary is often sourced from the Customer or Company record on transactions, and downstream transactions inherit it from the Created From. Therefore, you might also need to consider setting your customers to the desired subsidiary.
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.85553
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.851203
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.850820959
Please provide your feedback on this answer.