I have a script requirement that I am anticipating is going to take a long time to run and consume a significant amount of governance units.
I am wondering what the best approach to this is, and if there is any way to minimize processing time.
The task:
Allocate unique identifiers for each unit listed on a purchase order. The unique id is sourced from a custom record. The custom record is essentially a list of over 50,000 unique id entries. As an entry is taken the custom record it needs to be updated with the po # that it was allocated on.
For instance, a PO is put in for 3 different line items. Each line item has a quantity of 1000. We need to allocate 3000 unique ID's.
Given that saving a record can take some time (and discarding governance) I've ruled out user event scripts and am left with scheduled scripts to process the work load.
My thought is to have a script similar to the following psudo-code:
1. Run a search to get unassigned PO’s 2. For each PO in the result set, do the following: a. Open the PO b. Count the line items c. Run search to get unused UID's (UID where invoice number is blank) i. For each row in the result set, do the following * Update the UID record to show item is assigned by the invoice number from step 2a. * Save the UID record d. Update the PO to reflect UID assignment.
I'm concerned about governance here though. From what I can tell (and I'm hoping my math is incorrect, please correct me if it is) we have the following formula to calculate governance: 10+(numPos*10)+(totalLines*10)+(totalQty*6)+(20*numPos) In production one of our PO's would consume 51284 governance units using the above formula. (16 lines, total qty of 8514)So please tell me either I'm way off on my governance calculations, or if I'm barking up the wrong tree (and please point me in the right direction if possible). I've yet to start writing the script, and I'm not looking for handouts - just trying to determine best course of action.