I have a suitelet that has two sublists. The first...
# suitescript
e
I have a suitelet that has two sublists. The first sublist has a custom button using sublist.addButton and the second sublist has a refresh button using sublist.addRefreshButton. The goal is to refresh the second sublist using the refresh button after using the custom button to add a new row to the custom records table. I don't want it to refresh the whole suitelet form, just the second sublist. The client script does"not see" the sublists. What are the viable options of doing this?
a
not sure I've fully understood. your suitelet creates a form on GET request that form response has two sublists sublist 1 has a custom button which is used to add new rows to sublist 1 sublist 1 rows are actually creating new custom record entries sublist 2 is a read only list? of the custom records that are created via sublist 1 new lines? the sublist 2 button(refresh) doesn't just refresh the sublist (desired) but rather resubmits the initial get request to the suitelet
the refresh button is going to do a refresh, that's what they do, so step one is going to be removing that refresh button and replace it with a second custom button
its weekend so not looking at code or docs... so this is just from memory.... i think you're gonna want to set that second custom button to call the same GET suitelet again but have it pass in as a parameter the ids of the new custom records you've created? but that is a full server side request/response cycle with a new pageload it sounds like you want to just be able to do it client side but I'm not sure that's possible, though i feel like it should be, just not sure what the pitfalls might be the sublist TYPE might come into play here, i think there 4 different ones? and they all act a little differently, but you may have other requirements that limit your ability to change from the ones you've already chosen.
e
sublist 1 has a custom button which is used to add new rows to sublist 2
i tried all sublist types but have only had success using the LIST sublist type. and yes i just want that refresh button to refresh the sublist since from all indications, it is a button added on that particular sublist and should technically only affect that sublist otherwise what's the purpose of a refresh button on the sublist level that will refresh the whole page?
a
right sorry, was mis-remembering - switched computers now. 🙂 so your sublist refresh button is doing a full page refresh?
image.png
or its just not refreshing the list the way you think it should?
e
yeah it's not refreshing the sublist which is what i would expect it to do
a
so is your first button to create lines on sublist 2 is working correctly?
but once those lines are added... you're trying to refresh that list? and... it removes the newly added lines ? or...? something else?
e
yes once the custom records are added it is not doing anything when you click refresh. in other words if i had 2 custom records on that sublist and i added 1 record using the custom button on sublist 1 i should expect to see 3 custom records on sublist 2 after i click on the refresh button.
a
okay so your custom button IS creating the new custom records... but they're not showing on list 2 immediately, and they're also not populating when you refresh?
👍 1
ok so just reviewing the sublist types... LIST says you cant add lines?
image.png
so does your initial suitelet GET do a search of some kind for these custom records, and populate sublist 2 on load?
👍 1
cos all the refresh button appears to do is recall the suitelet, and take the generated HTML for the sublist which has been refreshed and replace that HTML node with the new refresh data from the suitelet
I'd suggest the new custom records you're creating on sublist 1 are missing some attribute that's being filtered for in your suitelet search/query, and so even tho those new records are being created they aren't being included in your sublist2 list on refresh
e
the datasource for sublist 1 and sublist 2 are different. sublist 2 is being populated by a saved search.
a
check your filters on that saved search or even recreate it in the ui as a saved search, and check your search results.... are your new custom records that you're creating showing in the search results?
e
yes they are
a
ok... that is surprising
if you open the suitelet again and it loads the full page do the new records show on the first load?
e
yes they do
a
both your sublists have ids, and they're different from each other when you do the form.addSublist?
Copy code
let sublist1 = form.addSublist({
          id: "sublist1",
          type: serverWidget.SublistType.LIST,
          ...});

 let sublist2 = form.addSublist({
          id: "sublist2",
          type: serverWidget.SublistType.LIST,
          ...});
go to your suitelet page, open the dev tools (F12) go to the network tab clear the history then click the refresh button the top entry scriptlet.nl .... will give you the requset/response data for the refresh request the preview and response tabs show you what's coming back from the suitelet the contents of the sublist in this response should be the exact same thing as what comes back for the content of the sublist if you do a full F5 refresh
I can only think of two things that might mess this up 1. you've got some kind of conditional logic when populating the sublist that is somehow skipped on the refresh 2. NS is just too dumb to handle two sublists even though they have their own ids and its just losing its mind
e
ok thanks and yes each sublist has its own id
r
The short answer is you can't. The page needs to be refreshed to have the newly created record in the new sublist if the sublist is of the list. Or you can use the inline editor sublist type. Where you create your custom refresh button which is actually gonna remove all the line on the sublist, do a query/search and recreate all those lines. Although I do not like the second approach. And don't remember if it was possible 100%. But you can try that.
a
this is patently not true for sublists of type LIST I have one that has no results, I edit some records so it meets the criteria, i refresh the sublist, not the page, and I get the now valid results. so what specifically do you mean you can't have the new records show up? something related to the fact that there's two sublists?
r
This is new to me i always thought that refresh, will refresh the entire page and not just sublist. Will check it out, thanks.