Hi all, I am writing a data directive to email when receipts are entered.
foreach (var bpm_row in ttRcvHead) {
int po_num = (int) bpm_row["PONum"];
string company = (string) bpm_row["Company"];
var receipt_date = bpm_row["ReceiptDate"];
var receive_person = (string) bpm_row["ReceivePerson"];
bool received = (bool) bpm_row["Received"];
if (!received) {
return;
}
var lines_on_po = (from rcv_dtl in Db.RcvDtl where rcv_dtl.PONum == po_num select rcv_dtl);
string _out = "";
foreach (var sql_row in lines_on_po) {
var r_ps = sql_row["PackSlip"];
var r_po = "Line " + sql_row["POLine"] + ", Release " + sql_row["PORelNum"];
var r_location = sql_row["WareHouseCode"] + "/" + sql_row["BinNum"];
var r_operation = sql_row["ReceivedTo"];
var r_our_qty = sql_row["OurQty"];
var r_part_num = sql_row["PartNum"];
var r_part_description = sql_row["PartDescription"];
_out += $"---- {r_ps} ----\n {r_po}\n Location: {r_location}\n Quantity: {r_our_qty}\n Part Number: {r_part_num}\n Part Description: {r_part_description}\n Receive Person: {receive_person}\n Receipt Date: {receipt_date}\n \n ";
}
// email '_out'
}
This returns no rows, but since it’s a data directive shouldn’t the rows be in the database by this point? I am able to get rows to show up if I expand the search to other PO numbers, so I know the code is functional. Any help would be fantastic. Thanks!
var lines_on_po = (from rcv_dtl in Db.RcvDtl where (DateTime) rcv_dtl.ReceiptDate == (DateTime) receipt_date select rcv_dtl);
This code returns all the receipts from today, excluding the new rows. I need to know the part and quantity of the PO receipt, but the ttRcvHead fields are limited.
It really depends on the data you want in your email, but you probably don’t even need RcvHead. A new record in RcvDtl is a pretty good indication something has been received, and it has data like part number, received quantity, etc, right there. Unless you wanted to do something semi-tricky like show the vendor name this should be pretty simple.
Looking forward to the thread you create in a few weeks asking how to turn this off because people are complaining about getting too many emails.
string text = "";
foreach (var row in ds.RcvDtl) {
var r_po = row["PONum"];
var r_tran_type = row["TranType"];
var r_packslip = row["PackSlip"];
var r_arrived_date = row["ArrivedDate"];
but many of the fields I want are not filled for some reason.
I don’t know if it matters here, but you are doing that inside a for loop.
That will exit the whole bpm.
If you want to exit the bpm, that’s fine, use return;
If you want to exit the for loop altogether use break;
If you want to short circuit and go to the next record in the for loop, use continue;
When a new receipt entry is filled & received is checked, and the part is in our warehouse, an email should be sent out containing the contents of the received items including part descriptions
This does matter- thanks, but it won’t fix my issue unfortunately.
To me, this sounds better suited for a BAQ report that is processed on a schedule. Pull all the tables and fields you want into a BAQ, make a report, set it up with APR and then set up a schedule to run it. Emails get sent out to the target audience with a summary of what’s been received in the last week/day/hour/minute… whatever interval you choose.
Unless you need split second alerts, this seems a little easier to manage.
If more real time is needed, we could also schedule a function to run a few minutes after receipt, to guarantee everything is written. (If that is in fact one of the issues here.)
Yeah, it would have to be shortly after receiving. If certain parts come in, we may want to begin work using those items immediately and the email would save time