[Custom sublist] [UserEventScript] I added a new ...
# suitescript
d
[Custom sublist] [UserEventScript] I added a new sublist via my UserEventScript. The codes for adding the lines to my sublist are found in the BeforeLoad event. My sublist has also a custom to attach a new invoice to my sublist. The function called by the button is found in a clientscript. The problem is that I cant refresh my sublist from my clientscript, so to view the new line attached, I have to refresh my browser in order to see the new line since the sublist is filled in the beforeLoad event. Is there any way to add a line to my sublist without refreshing the page?
b
what does your button to add lines look like
keep in mind you may have to share what the beforeLoad looks like
d
beforeLoad(context){ var form = context.form; form.clientScript...='Suitescripts/...'; var sublist = form.addSublist(...); var sublist.addField(..); var btnAdd = sublist.addButton(..); }
b
you've actually hidden the information i would have wanted from the beforeLoad. specifically the ids and types of the ui objects you are adding
you can make up fake ids if you keep them consistent between the client script button and the beforeLoad
more important is whatever client script you are using to attach invoices
d
try{ var GI_Rec = currentRecord.get(); //get currentRecord of custom-Record var invoiceID = GI_Rec.getValue({fieldId: 'custrecord_dropdownlist_invoice'}); //get Id of invoice from custom dropdown list of invoice var GI_internalId = GI_Rec.getValue({fieldId: 'id'}); //get id of currentRecord var invoiceRec = record.load({ id: invoiceID, type: record.Type.INVOICE, isDynamic: true }); invoiceRec.setValue({ fieldId:'custbody_grouped_invoice', value: GI_internalId }); //modify value of custom field in invoice, so that the line will meet filter criteria of search in UserEvent. invoiceRec.save(); location.reload(true); //reload page to launch UserEventScript again } catch(e){ } }
b
that doesnt really do anything to the sublist, so its not surprising that nothing happens
if your sublist is one of the editor type sublists, you could just add lines to it
if your sublist is a list, you can try adding a refresh button to the sublist
though i've only used that with suitelets and don't know how it works with normal records
as an alternative, you may want to try marking the
Record is Parent
checkbox on your transaction body field named
custbody_grouped_invoice
. NetSuite has built in functionality to create parent/child relationships
d
Of course it wont do anything to the list because the sublist must remain static (not editable). I used the built in relationships but the problem is that the generated transaction field has not only invoice but other types of transactions such as itemfullfilment, sales order, purchaseorder. The client doesnot want all those options in the dropdown. I cant modify the dropdown list because it is generated through builtin relationship
b
have you tried a filter for the field under the sourcing and filtering options
d
When you create a parent field in Invoice, I automatically get a child field above my sublist in custom form. I cant see that field in form-customization to add filters.
b
then the only thing i have for you is a list type sublist with a refresh button