I’m building a Suitelet that displays a custom su...
# ask-stanley-ai
m
I’m building a Suitelet that displays a custom sublist (SublistType.LIST) with Purchase Order lines. Each line includes a checkbox (custpage_select) and an editable field (custpage_qty_to_receive). I want to allow users to: • Check multiple lines • Modify the quantity to receive (custpage_qty_to_receive) manually • Then click a custom button (Generate Item Receipt) that triggers a Client Script to: • Read the selected lines • Read the edited quantity from each line • Generate a grouped payload to send to a Map/Reduce script via a hidden form POST The issue is: When the sublist is in LIST mode, the currentRecord.getSublistValue() API does not reflect the updated values of the editable field (custpage_qty_to_receive). Only the checkbox state is preserved. I tried switching to INLINEEDITOR, but then checkboxes stop being readable on the client side. I also tried accessing the values via the DOM (document.querySelector(...)) and that works, but it feels unreliable. What’s the best practice to handle a Suitelet sublist where users need to both select lines (via checkbox) and edit a numeric field, and then trigger logic via Client Script?
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems that the issue you're facing is a common one when dealing with Suitelet sublists of type LIST. The problem is that the SuiteScript API does not allow you to directly modify the values of a sublist of type LIST via a Client Script. However, there are a few workarounds that you can consider: 1. Change the Sublist Type to INLINEEDITOR: This will allow you to modify the sublist values via a Client Script. However, as you've mentioned, this will make the checkboxes unreadable on the client side. To overcome this, you can make all the fields that you don't want to be edited as DISABLED. 2. Use DOM Manipulation: As you've mentioned, you can access the sublist values via the DOM using
document.querySelector(...)
. While this method works, it is generally considered unreliable and not best practice. 3. Use a Map/Reduce Script: You can use a Map/Reduce script to read the selected lines and the edited quantity from each line. This script can then generate a grouped payload to send to a hidden form POST. 4. Refresh the Suitelet: You can refresh the Suitelet after the user has made their selections and modifications. This will allow you to read the updated sublist values. However, this method may not be ideal if you have a large number of lines in your sublist. Remember, the key is to ensure that the sublist type and the method you use to read and modify the sublist values are compatible. If they're not, you'll need to find a workaround that suits your specific needs. ****** 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.869036078
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.864794612
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.864732683
Please provide your feedback on this answer.