Is there a hook for me to tie into completion of t...
# suitescript
c
Is there a hook for me to tie into completion of the Run Billing Operations? (Transactions > Billing > Process Billing Operations) I'm not finding anything. I want to run a map reduce script that groups invoices by contract after the billing operations have completed. The map reduce script works fine, however I am not finding how I can tie it to the completion of the Run Billing Operations process I've reviewed related SuiteAnswers articles, though am not finding the exact article that I need. I found some articles that suggest I use a scheduled script to periodically pick up the invoices: 67449. The problem with the scheduled script solution is that I want it to run automatically after the billing operations has finished. I don't want my user to have to click a second button to trigger the script or have to wait for the schedule to pick up the grouped invoices. I found other articles that suggest I use an after submit on the invoice: 87747, 47805 The problem with this solution is that the Billing Operations is a process instead of a record. Therefore, I would have to tie the after submit to the invoice instead of the billing operation process itself. Since billing operations creates multiple invoices, I would need to find a way to see if the billing operations is currently running so I don't kick off the grouping too soon. I've also seen some articles that suggest I can put the the aftersubmit on the billing schedule. I think this was a suiteanswers AI hallucination. I don't want it to run after a billing schedule, but after a billing operation has run. Second Question: Also, can I add a checkbox on the Billing Operations page to kick off my map-reduce script? From what I see, that page is not customizable and I would have to to write a suitelet that mimics the Billing Operations page. Is that correct? Also, is there anything that I have incorrect in my above assessment or am overlooking? I would really appreciate any help.
a
99% sure you're not gonna be able to tie into billing operations to trigger your MR. this feels like the type of problem that you shouldn't have, the solutions I've been pondering all feel really clunky and bad, which makes me think this should be done somewhere else? I'm not that familiar with billing operations but it does allow for grouping, is it not possible to incorporate the contract grouping using that feature?
c
I put a ticket in with NetSuite asking if they can group by Contract, and they can only group by Customer. 😞 I think I'll have to run the base "Run Billing Operations" to create the invoices and then Call the Map Reduce to group by Contract as a second step.
a
okay well FWIW my clunky solution... have a scheduled script / MR that runs every 15 minutes with two script params script param 1 = invoice count t-minus-15 script param 2 = invoice count t-minus-30 when the script runs it just does a simple search/query to get total invoice count then it compares the current invoice count with t-15 and t-30 if current invoice count == t-15 && current invoice count > t-30 trigger your existing MR to do the contract grouping update script deployment with new params t-30 = t-15 t-15 = current
this should prevent it from running while billing Ops is still in progress, and will run when its finished, with a potential delay of at most 15 mins after billing Ops is complete
I'm assuming that you can update script params on deployments but I'm not actually sure you can do that with suitescript?
c
So basically watching to see if new invoices have been created?
👍 1
I'm not sure about params on deployments. I could probably use a hidden field/record to store the count
a
yeah a custom record with just 1 record works too