Rick Goodrow
01/13/2025, 12:32 AMFreight Quote
. These are used to track and get quotes for shipping from our carriers. I added a custom sublist custsublist_uv_fq_sublist_freight_quotes
to the Sales Order record of Freight Quotes linked to the transaction (Screenshot shows this). My preferred interaction is that the user can click a button from this sublist to update the Shipping Cost
on the transaction to the Customer Cost
on the Freight Quote. This part I have working through
• Saved Search that powers the sublist, the last column is a Formula (HTML) that returns <button data-fq-cost="{customerost}">Update Shipping Cost</button>
.
• jQuery('[id="shipping_div"]').on('click', '.uv_fq_update_shipping', function(e) {
function on pageInit to listen to click events on buttons loaded into that sublist.
(I know I'm working outside of "official supported SuiteScript", but trying to make updating shipping costs easier and quicker for my users).
My challenge now, is that I only want the button to appear when the transaction is in EDIT
mode. Ideas
• Update the Formula (HTML) field on the saved search to include style="display: none;"
on the button, then removing that when record is in edit mode.
◦ can't use beforeLoad of Sales Order, because scriptContext.newRecord.getSublistFields({ sublistId: custsublist_uv_fq_sublist_freight_quotes,});
returns an empty array, even though on the transaction itself it's visible
▪︎ oddly when I inspect the Freight Quotes sublist div, it's got references to customsublist47
, but not references to the actual ID of the sublist
◦ Another option is a jQuery event listener for dom manipulation, but I don't know a way to specifically target that sublist for same reason as the sublist not using the custom ID specified.
• Get rid of the Formula (HTML) column and dynamically create the button on each row
◦ same problem as above, I don't have a way to target just that sublist before the XHR request or dom manipulation happens.jen
01/13/2025, 11:54 PMRick Goodrow
01/14/2025, 1:49 PMconsole.log(scriptContext.currentRecord.getSublist({
sublistId: 'custsublist_uv_fq_sublist_freight_quotes'
}));
just returns an empty array, but if I use GUI to go to that sublist, then it performs the XHR and I can see the datajen
01/14/2025, 3:17 PMNElliott
01/15/2025, 10:19 AMRick Goodrow
01/15/2025, 2:19 PMscriptContext.form
to build the Sublist through code on beforeLoad
Rick Goodrow
01/22/2025, 5:42 PMbeforeLoad
on the transaction record to use scriptContext.form.addSublist()
to create a custom sublist, adding fields for columns I want.
• Running a saved search to get the values for the sublist
• using scriptContext.type
to determine what mode, and change values in the sublist column depending on result
• Despite the column being defined as
freightQuoteSublist.addField({
id: 'custpage_uv_fq_subfld_actions`,
label: 'Actions',
type: 'TEXT', // <https://5858307.app.netsuite.com/app/help/helpcenter.nl?fid=section_4332671056.html>
});
• when I provide html, it is actually rendered as html on the webpage
• Adding code inside a Client Script pageInit
hook on the transaction using jQuery to grab the click
event bubbling up from the resulting table created by the sublist.
• One note I noticed, is that if you create a custom sublist via code, then the id
attribute of html is actually <sublist_name>_layer
, whereas if you create a custom sublist via the UI under customication, the id is customlist47_layer
. This was what was blocking me previously.
• By creating it via code, it properly uses the custom id as html ID attribute, allowing me to hook into the table via jQuery and capture the events. Resulting client script code below.
// Bind to the sublist so we can catch new ones if possible
jQuery('#custpage_uv_fq_sublist_layer').on('click', '[data-uv-action="' + uvFQLibID.jQuery.action.SET_SHIPPING_COST + '"]', function() {
let that = jQuery(this);
let prevHtml = that.html();
that.prop('disabled', true).html('<span class="material-symbols-outlined uv_progress_animate">progress_activity</span>');
scriptContext.currentRecord.setValue({
fieldId: 'shippingcost',
value: parseFloat(that.data('data-uv-cost'))
});
that.prop('disabled', false).html(prevHtml);
});