Delete UD Field By BPM

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?

Yes. If just by order it’ll bring them all up. But, I want to delete everything associated with that order.

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.

Hope that helps.

@Will79 You can do this with updateExt like in this thread.


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…

UGG…So, guess that means I have to use Custom Code… Not my favorite.

I’m somewhat surprised they don’t have a looping widget of some sort.

That’s probably the best thing about workato, actually!

I’ve never tried, but can you fill a dataset with one widget, update RowMod to “D”, and call update on the dataset? :thinking:

Depends on the method, but most of them only accept a single change at a time. There are a few that accept multiples, but I don’t run across them very often.

I was thinking the GetRows may give me all the rows. It requires a where in the parameters. Not sure what to do for this one.

What about something like this?

// 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.

1 Like

Thank you! Very helpful!

I’m back to working on this now. What I have done so far is a Method Directive on CustShip Update. I’m not real good at coding, so any help is appreciated.


Invoke ICE.UD25

Execute Custom Code:

UD Key fields are:

Key 1: Ordernum
Key 2: Department
Key 3: Pallet Size
Key 4: Empty
Key 5: Empty

Want to delete all rows with the same Ordernum.

Make sure you use a post method - you probably don’t want the records deleted if the order doesn’t save for some reason.

The example below does something similar but with AR invoices and UD11. It deletes all records with Key1 equal to strino. Also, below is just for Key1 as that’s all I needed. You’ll need to extend that to keys 2-5. I used this in a standard data directive and nothing is tested.

// get all rows
bool tbool;
Ice.Tablesets.UD11Tableset tsUD11 = new Ice.Tablesets.UD11Tableset();
tsUD11 = ud11sc.GetRows("Key1='" + strino + "'", String.Empty, 0, 0, out tbool);
for (int i=0; i<tsUD11.UD11.Count; i++)
  ud11sc.DeleteByID(tsUD11.UD11[i].Key1, tsUD11.UD11[i].Key2, tsUD11.UD11[i].Key3, tsUD11.UD11[i].Key4, tsUD11.UD11[i].Key5);

LE: cleaned up the code.