Function updating DB table

I am attempting to save a calculated value in a function following this post:

My functions is set to requires transactions and library is set to DB read/write
I also have added the assembly reference to Erp.Internal.Lib.CCredChk.dll

The code syntax check has no errors except this one:
The type 'TransactionScope' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Transactions.Local,

but when I go to add the reference is does not appear in the list of available assemblies

This occurs on the line:
using(var txScope = Ice.IceContext.CreateDefaultTransactionScope())

thx

In my experience, if your function has the ‘Require Transaction’ option checked, you shouldn’t need to wrap your code in the transaction scope manually. That checkbox does the work for you.

The combination of that option checked, plus your code, might be causing a conflict.

2 Likes

I previously did not have it checked, tried turning it on because of the error

Try removing the using(var txScope...) statement in your code, but leave the checkbox checked.

okay, that get’s rid of the error (of course), now to see if it actually updates the data, thx

Yeah, there’s something fundamentally wrong here (with me probably)

I created a new function with a simple test,
grab an order line (orderNum and orderLine are input parms to my function)
update one of my user defined fields…

nothing changes

this is my code:

var orderDetails = Db.OrderDtl.Where
   (k => k.OrderNum == orderNum && k.OrderLine == orderLine &&
    k.Company == this.callContextClient.CurrentCompany);
    
var orderDetailsRow = orderDetails.First();

orderDetailsRow.AddOrderComm_c = "test add order comments";

I call the function via Rest API Helper, I know I’m finding the order line because I stuff debug strings in my output (response parm)

Requires Transactions is on, Function library is read/write

You need to call save changes on the Db Object.

Also, on the Tables tab, make sure that specific table is selected to be updatable.

3 Likes

omg, always the simplest things to overlook, thx, that helped

1 Like