in the client script, set up your function to hand...
# general
a
in the client script, set up your function to handle the button click, which i guess would load the record (you'd need to pass the internal ID of the record through to the client script), and then loop through the line items