I want to copy a UD field from the OrderRel table to ShipHead table when a packing slip is created.
I created a Data Directive on the ShipHead table and added a Set Field with the following code.
(from x in Db.OrderHed where x.Company == ttShipHeadRow.Company && x.OrderNum == ttShipHeadRow.OTSOrderNum select x.UDField(“Ref_c”)).DefaultIfEmpty("").FirstOrDefault()
When I check the syntax I get an error code CS0854 An expression tree may not contain a call or invocation that uses option arguments.
but if I substitute the UD field on the OrderRel table with a regular table field, it works.
Do I have a syntax error? or is it using the wrong schema by change? or must I use a Method Directive?
any help would be appreciated .
Different places in BPMs accept slightly different versions of UD fields. I can never remember which is which so usually swap them out as I get the errors.
One of them usually works.
Tried those and none of them worked
Try leaving out your DefaultIfEmpty. You shouldn’t need it, I think. Put a data type before what you have and a fallback if null, and the FirstOrDefault should be enough.
I just ran into this same situation I needed a UD from InvcHead to copy to Cash table. I tried all three methods I knew, which @dhewi already mentioned:
I ended up declaring the entire table then pulling the UD. It’s not a nice and I’d love to find a way so if there is a trick please let me know.
var inv = (from ih in Db.InvcHead.With(LockHint.NoLock)
where ih.Company == Session.CompanyID && ih.InvoiceNum == invoiceNum
if(inv != null)
if(inv.UDField<string>("StringUD") != "")
NewTableUD = StringUD;
I’ve used a method directive, using Update Table by Query.
I my case, I wanted UD fields from Part to pass to OrderDtl
in SalesOrder.Update, Pre-Processing, put a Update Table By Query (just Start > Update Table by Query)
Configure the Update Table By Query with 4 params:
Use the MyQuery query parameter to make a BAQ from Part with Company and PartNum, plus the two Part UD fields I want to go to OrderDtl.
Query to Update changed rows
of ttOrderDtl table with…
in relations, set the field that will be the match. In my picture, ttOrdreDtl.Partum will match with my Query’s Part_Partnum
and the column OrderDtl.NQF_c will match with my query’s Part_NQF_c
and OrderDtl.Dependent_c matches with query’s Part_Dependent_c
I did method directive, update table by query. I wanted my UD field to be passed from OrderDtl to OrderRel. in SalesOrder.Update, Pre-Processing, Update Table By Query; I linked OrderDtl to OrderRel in the query and displayed Company, OrderNum, OrderLine and the UD field from OrderDtl that I want to go to OrderRel. Changed update to “all rows” because I want the OrderRel column to always be the same as the OrderDtl column. I chose the ds.OrderRel table, with configured mapping. In relations I linked OrderNum to OrderDtl_OrderNum, OrderLine to OrderDtl_OrderLine, Company to OrderDtl_Company; in the columns I bound my custom column from OrderRel to the custom column in OrderDtl. Once I saved and reopened the Order Entry - Release List view, the column did not have the value in it like it should. Is there something I forgot to do?
You need to figure out which tables are actually in memory when you do the save. You may not have the applicable rows there to update from within the call, or if you do, they may not have a row Mod set, so the BO doesn’t know that you want it changed.
Use message boxes to see what is actually in the dataset when you do it.
Just curious, can you create new column maps in column map maintenance? Or are the default map ID the only ones to choose from? I want source table OrderDtl and target table OrderRel
I don’t think you can. It would be nice if you could, but if the relationship isn’t there, you can’t (as far as I know)
How would I add message boxes in this exact method directive I am trying to create? Do I just link the Show Message box to the update table by query? Or is there something else?
The BPM engine is just a flow chart. You add a widget, then connect one the the next and it does them in order.
I’m assuming you don’t know this, so I’ll give you a hint, in the message box design window, if you right click where you type the message, it gives you options of variables to put in there, and you can do field or table queries and it will display what you select. That was you can see what tables, and what data is being passed. Sometimes what you “Think” should be there isn’t, and once you see the data, you can understand what your problem is.
Will that message get displayed on the field or somewhere else?
It’s a popup when the BPM fires.
I assume this should fire as soon as the Order is pulled up?
I don’t mean to be rude, but from the questions that you are asking, you need to get some basics under your belt before you attempt this.
Go to the tools user guide and read up on BPMs. There are even case studies that walk you through some cases step by step. The one below looks like it’s pretty close to what you are doing.
So I went through this and followed it step by step. Should updating the field also update the column in the list view?
If it actually made the change, then yes. At the very least, you might need to hit refresh on the screen.
If it doesn’t work, then drop in message boxes in your method and make sure it’s firing.
If it’s not. Then you need to run a trace to see what methods are being used so you can put your BPM on the right method.