If we want to retrieve the values from fields in a...
# suitescript
m
If we want to retrieve the values from fields in a Suitelet > Sublist can we use the context.getParameter or do we need to use a ClientScript for this?
k
On post?
m
Yeah, on post. So I would like to check a checkbox is selected when the user submits a button click. Wasn't sure 1) how to get the checkbox value 2) if it can be done directly within the suitelet or if a client script was required
k
Yeah can be done on post by using the above object use the select checkbox loads.
m
Thanks for that. I am getting the internal id of a transaction and displaying it on the form. On submit I can't seem to access this value - log shows empty. Can you see why?
message has been deleted
Copy code
custpage_internal_id
Looks like this:
Copy code
sublist.addField({
    id: 'custpage_internal_id',
    label: 'Internal ID',
    type: ui.FieldType.TEXT
});


sublist.setSublistValue({
    id: 'custpage_internal_id',
    line: counter,
    value: internal_id
});
k
In post context.request.getLineCount(sublistid); for loop on line count Then within use context.request.getSublistValue() That api function takes sublistid, fieldid, line.
You can also get the sublist fieldids and create an object from the fieldids and values if you have values set on line items.
If you need a sample DM me and I’ll send one over when I can.
m
Thanks. I am defo setting the internal id here:
Copy code
if (internal_id) {
    sublist.setSublistValue({
        id: 'custpage_internal_id',
        line: counter,
        value: internal_id
    });
}
I made internal_id global variable. Inside else the log says untitled. Else looks like this
message has been deleted
k
Your getSublistValue needs to be inside the for loop. I would also do an array.push as I assume your sublist could have multiple lines.
var salesOrdersToPrint = [];
Then in the for loop salesOrdersToPrint.push(getSublistValue)
Not the full code but you get the gist
Are you only setting the internalid value as a test?
I assume your going to display a sublist full of actual sales orders at some point with filters etc that would update on Cs?
m
Ah yes, damn, that was silly. I can access the value now. Yeah, internal was just a test.
k
Ok cool! Lots you can do with this way of working with sublists in a suitelet
m
Correct, so I can get a list of SOs and display it. I need a way to allow user to print one. So I added a checkbox on each line - so when they select one, I need access to that line's internal is so I can then print the pdf when they hit the Submit button
This is actually my first SL - was a bit of a pain, but slowly making sense!
Thanks for your direction - saved me ages of time!
k
Yeah so array of internalids and then pass to a print function to print transaction and group them together.
Then file to the response. Relatively simple and can be used for all record types.
You can also make the response inline to show in the browser first.
Hope you can get there. Ping me if anything else.
👌 1
m
Is it at all possible to highlight the rows or not really?
312 Views