Hello, My client would like to select the Project ...
# ask-stanley-ai
m
Hello, My client would like to select the Project on the Sales Order header, and then have a field at the line level that dynamically displays the list of Tasks associated with that selected project. I’ve tried using field sourcing, but it doesn’t seem to work. Is there anyone who can assist with this?
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems like you are trying to source a field at the line level based on a field at the header level. This is a common requirement in NetSuite, but it can be tricky to implement. The issue you're facing is that the sourcing of the project field from the parent to the child will only happen when the record is saved, not while they are in the UI editing the parent record. This is a limitation of NetSuite's UI. To overcome this, you can use a client script. The script should trigger on the fieldChanged event of the parent project field, and then loop through the child lines to set the project value on each line. This will ensure that the project field in the detail is automatically populated. As for the task field, you can use a similar approach. You can create a client script that triggers on the fieldChanged event of the project field in the detail. The script should then filter the tasks based on the selected project and populate the task field accordingly. Here's a pseudo-code example of how you might implement this:
Copy code
javascript
function fieldChanged(context) {
    if (context.fieldId === 'custrecordbea_sp_oc_proyecto') {
        var project = context.currentRecord.getValue({
            fieldId: 'custrecordbea_sp_oc_proyecto'
        });

        context.currentRecord.selectLine({
            sublistId: 'customrecordbea_sp_orden_de_cambio_det'
        });

        context.currentRecord.setCurrentSublistValue({
            sublistId: 'customrecordbea_sp_orden_de_cambio_det',
            fieldId: 'custrecordbea_sp_oc_proyecto_st',
            value: project
        });

        context.currentRecord.commitLine({
            sublistId: 'customrecordbea_sp_orden_de_cambio_det'
        });
    }
}
****** 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.838334799
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.821964622
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.820503354
Please provide your feedback on this answer.