0
votes

I'm hoping someone can help. I recently wrote a SuiteScript 2.0 project. The primary suitelet displays transaction/customer info in a sublist that has a SublistType of LIST. Right now we're displaying 750 records in the list at a time, but there can potentially be hundreds or even thousands of additional records, so the users want to have a Next and Previous button that will allow them to cycle to the next page of results.

The problem is that I cannot seem to update that sublist for the life of me. The fields on the sublist are all text fields except for one checkbox. Inside of a CLIENT SCRIPT, I've been trying things similar to the code below. (I removed all but one of the setCurrentSublistValue calls to shorten the code):

var currentRec = currentRecord.get();

currentRec.selectLine({
    sublistId: 'custpage_studstatement',
    line: 0
});

currentRec.setCurrentSublistValue({
    sublistId: 'custpage_studstatement',
    fieldId: 'custpage_show',
    value: false
});

currentRec.commitLine({sublistId: 'custpage_studstatement'});

It will spin through all of the sublist items, but ONLY the checkbox gets updated. None of the text fields change, and no exceptions are thrown.

If I change the sublist to type EDITOR, I can update all of the fields on the line without a problem. It basically behaves they way I want it to. Also, if I change the FieldDisplayType on any of the text fields, I can then update those individual fields, but neither of those options are acceptable. We don't want the users to be able to edit those fields/lines like that. The LIST sublist is the one we want, but I'm beginning to think you cannot update LIST sublists from a client script, even though the docs suggest that you can. (although it's not definitive. The docs are a bit sketchy)

So I guess I'm mostly just looking for a high level answer, because I'm not sure I'm even approaching this correctly. If you have a custom sublist that is just a LIST, how would you add the ability to page through to the next set of results? Should updating that sublist be done in the client script? If so, how? Or should it be in the suitelet? And if so, how? (I've tried some various things in the suitelet as well, but I'll omit that to keep this from getting any longer) Thanks in advance

2

2 Answers

0
votes

I am making a few assumptions here: Your suitelet creates a custom page - it has a sublist. The sublist is a form.sublist. and inside it are fields, sublist.addfields.

What you can do is use sublist.setSublistValue and it can populate the whole sublist.

Now, It depends on how you obtain the values of your sublist - you can have additional fields in the body - the bodys will define a filter that filters this search. This will scale down results shown in the page a lot to achieve the result you have.

You can indeed have next and previous page - of which you have your search object, and your next page/previous page button will impact your results.getRange() function - instead of for example getRange({start:0 end:1000}) to be getRange({start:1000 end:2000}) greater and beyond that. (This isn't the only way, but how I imagine I would do it)

Either way, how you get your dataset - a search.create will be in your suitelet, the getRange will be in your suitelet. How you setSublistValue will be in your suitelet. How you create your buttons will be in the suitelet.

But, the function that the button triggers will be in your client script, loaded via form.clientScriptModulePath = './xxx.js'; Something like that. This client script can trigger scripts via url.resolveScript, and trigger the suitelet to add params. Passing some parameter to indicate which 'page' to load (first set of results..second set.. etc.)

Hope this will point you in the right direction!

0
votes

You can not update the sublist in suitelet using Client Script and with sublist being LIST type.

You can create Next and Previous button and on click of these button you can again hit the suitelet url from ClientScript and passing the pagenumber parameter and displaying the sublist dataset in forward and backward direction depending upon the value of pagenumber.

For eg:- if you are displaying 750 pages at one time then the first time you press Next your pagenumber parameter will be 2 and you will show next 750 entries in the page.