In a custpage sublist that is added on a record in...
# suitescript
w
In a custpage sublist that is added on a record in beforeLoad, how can I get the values from in that table through Client SuiteScript? I thought I'd get away with currentRecord.get().getSublistValue({sublistId: 'custpage_id', fieldId: 'myFieldId', line: 0). But it gives me "SSS_INVALID_SUBLIST_OPERATION". Does it have to be a specific type of list? list/staticlist/editor/inlineeditor? Or isn't sublists added in before load available in clientscripts?
hmm... "A required argument is invalid or the sublist is not editable."
I'm guessing you can't add editable sublists on something other than wizards and suitelets
e
You have to use the DOM on client scripts for sublists created on the UE beforeLoad.
var table = document.getElementById('custpage_sublist_addresses_splits');
w
hmm, ok. I abandoned that route and created a hidden field with the values in a json-string. Then I convert that field's value to a CSV and download it with a button. However, the next hurdle is the 100000 char limit. I guess I have to split it up in multiple fields and concat them in the client function. I really don't want to create a suitelet to download the csv 😄
Or do you have any other suggestion? Maybe it's easier to convert the DOM into a json.
e
yes I use the &xml=T trick to load the page and JSON.parse the XML to get the data I need that way.
w
JSON.parse the xml? Can you run JSON.parse xml? mindblown
e
so are you just wanting to populate the custom sublist created on beforeLoad with data from NS? on the client script you can use the standard N/record functionality and just use the DOM to display the data.
var xmlDoc = jQuery.parseXML(xmlString);
💯 1
w
I want to add a sublist to a custom record in beforeLoad. Then I want a button to press to download the information in that sublist as CSV
e
so it's a custom record form where you need to add the sublist on the UE beforeLoad event and you need to populate the custom/dynamic sublist with data coming from some record or a saved search and download that data in CSV format via a button click on the custom record form?
w
exactly
The data comes from a fixed field length file that is linked to the custom record and is converted in the beforeLoad
e
ok so the data is not child data of the custom record?
w
nope
e
is the fixed field length file stored in the file cabinet and are you displaying all the fields/columns from that file on the sublist?
w
yup
It looks like your first suggestion with using the DOM might be the most compact
e
so to display the data on the dynamic sublist created on the beforeLoad you just need that DOM code i sent you and then loop through the fixed length data although you won't be able to load the file using a client script
w
Sorry, I'm populating the sublist in beforeLoad. So I just need to extract the data into a csv
Just need to get the headers as well.
Thanks for the help @Eric B
👍 1
Full code.
👍 1