Hello! I was wondering I could get some input on l...
# suitescript
s
Hello! I was wondering I could get some input on logic design. Our requirement: When we send Invoices to customers, they want to know the roster/students that participated in the course. Based on requirements we created a custom record
roster detail
which links to the invoice (record is parent). I’ve got my proof of concept working where when they print invoice PDF, it appends the XML/PDF to the record using a custom transaction body field. Challenge: Script is deployed on Custom Record so it works when I’m creating/editing a new custom record or attaching/detaching one to the invoice record from the sublist. However, I’m not sure how to trigger an “event” if the Invoice is in edit mode, and I add/remove the roster detail using sublist. For w/e reason my User Event afterSubmit script on custom record doesn’t get triggered. Any thoughts on how to approach it?
c
If you're in the UI, you should get client script events when the child record changes via the recmachcustrecord_xyz ID.
s
@creece always great to hear from you. Should I be creating a backend Suitelet that’s called by CS on Invoice and UE on custom record?
c
Hello. I assumed you were editing an Invoice in the UI so you can attach a client script to the Invoice and see if you're getting the events firing for deleting/adding child records.
s
I’ll try that, but if we directly import custom record with reference to invoice - it wouldn’t trigger a client event script, correct?
c
no. Imports can only call server-side scripts
and you have to check a box to do so when importing**
s
So in UI on the transaction record (or custom record for that matter), I should use CS.
c
yeah you can try that or you can also do a UE script on the Invoice that on beforeSubmit spins through the child records and you can do your text update then. That'll work with imports
s
^^^ that’s what I have right now. but I have it deployed only to custom record but the smarter thing would be to deploy it to Transaction record!
it does this funky thing where if you are in view mode, and remove a child record it doesn’t cause an update to the transaction.
c
You may need a UE on both the custom record and the Invoice. Depends on where the user always updates from. If they can delete a user from the custom record, then it would need to update the Invoice. When the Invoice is saved, you can spin through and gather up the data and update itself. Doesn't matter which record is modified at that point. This is also a really good use case for a custom data source Advanced PDF.