I’ve done a few of these already but this one seems to be a little extra.
Background: I was tasked with creating an interface where the end user could input data into UD25. The fields are as follows: Key 1: OrderNum; Key 2: Department, Key 3: Pallet Size; Key 4; Blank; Key 5: Blank; Number 01: Qty
Our shippers are able to use this in deciding what will fit ona semi trailer pretty easilya nd is handy. However, once the order ships, they want to delte the lines.
Setup: I decided on a BPM on ShipHed with a condition of ReadyToInvoice goes from false to true. I then invoked BO ICE.UD25 and went to setup the parameters.
Issue: There is nothing in the Shiphead for Key 2-5 to in ShipHed. I thought about using variables, but I am not sure it would delete the fields I am needing deleted.
You will need to get those other keys in order to use the DeleteByID method (or whatever it’s called). Are there multiple departments/pallet sizes per order? In other words, will there be multiple lines that will return if you did a lookup just by the OrderNum key?
As always, I’m not sure this is the best way… But, you could run a LINQ statement and pull in all UD25 records with Key1 = Your Order Num. Then, in your foreach loop, for each row get all the keys. Then you have what you need to do your delete.
I can’t recall if I have used the DeleteByID or if I just did a GetByID and then changed the RowMod to D and then hit the Update method for each row. I’m sure someone who knows better than I can comment on what is a better practice.
I’ve been working in this today and have one little issue. I am trying to pass the Ordrenum to to the BO for UD25 and it keeps telling me there is multiple order numbers. Makes sense as the shipment has two lines. I’ve tried to use .First(), but that errors out as well. Any ideas on how to pass only one OrderNum from ShipDtl in a BPM?
You can only delete one record at a time with widgets. If you have more than one record, (which is sounds like you do) you’ll have to loop through the records. While that’s doable in widgets, it’s a huge PITA…
// step through each row of results
foreach (var xRow in (from ttResults_Row in queryResultDataset.Results where ttResults_Row.Key1 == YourOrderNum select ttResults_Row))
using (Ice.Contracts.UD09SvcContract mySvc = Ice.Assemblies.ServiceRenderer.GetService<Ice.Contracts.UD09SvcContract>(Db))
mySvc.DeleteByID(xRow.UD09_Key1, xRow.UD09_Key2, xRow.UD09_Key3, xRow.UD09_Key4, xRow.UD09_Key5);
This is from a dashboard where I delete UD records that are checked off by the user. It might take a few syntax changes to get it to work in the directive you want.