ErpContext accessing UD column for update purposes

Trying to update a UD column and I think I’m having issues with having the correct dll’s attached as references. I’m using client dll’s. Along with the initialization of the ErpContext. First, if I try to include Ice.Tableset.BpmDataRow I get “Are you missing an assembly reference”. I ransacked the dll’s for BpmDataRow and tried referencing each dll, but no luck. What dll needs to be added to resolve?

If I comment that out, I then get an exception trying to initialize the ErpContext() as shown below. In this case, I think I’m missing a configuration file. I have the environment.sysconfig file available and can execute other Impl transactions, just not the ErpContext.

using Ice;
using Erp;
using Ice.Contracts;
using Ice.Tables;
using Erp.Tables;
using Ice.Tablesets;
using Erp.Tablesets;
using DotCommon;
using DotitBllDal;

namespace OneOffReadyToInvoice
{
public class ShippingNotification
{
private static ErpContext db;
private static ShipHeadTable ttShipHead;
private static Ice.Tableset.BpmDataRow callContextBpmData;

    public static void UpdateFlag()
    {
        db = new ErpContext();

why are you trying to create a new erpContext ? Is this for a BPM? If so that context should already be provided for you.

I don’t use BPM’s. All of my code uses the BO’s to directly make updates and changes to the system. But in this case I just need to update a UD field. Unfortunately it’s a “EmailNotificationSent_c” on the erp.shiphead_ud table. If I try to do a MasterUpdate on the ShipHead record it errors out since the shipment has been marked complete.

I have a process that kicks off once a day, reads all shipments with EmailNotificationSent_c set to false, loops through building an email with tracking information along with details of what is in the shipment, then sends.

I was told that I could use the ErpContext just like a DataContext in Linq so I was using Epicor instead of doing a direct update to the database.

The MasterUpdate does work if the shipment occurred that day. If it gets a shipment from a couple of days ago, the MasterUpdate fails, thus I can’t update the flag and it sends a new notification the next day. Some of my customers have found this to be very annoying.

I recommend you write an updatable BAQ in Epicor which updates the field you want then you can execute that BAQ via the BAQ Business object.

Invoking/creating your own DB Context or doing direct SQL updates is generally frowned upon.

1 Like

Just a tought… have you tried to set the shipcomplete to false, save and then set your email flag to true, and shipcomplete to true, then another save. This was allowed to me manually with the Customer shipment entry form…

I have a similar problem in that I need to have a reason code applied for any late shipments. So in my case the shipment is generally shipped and the customer has been invoiced. I have written an updatable BAQ as you suggest but I cant seem to get around the problem that the business objects enforce (“Packing Slip is not open. Cannot update.”). I am guessing that I need to supply my own base code instead of the default base code to get around this but am struggling to find any example code that would show me how to accomplish the task. Any help would be appreciated.

After poking around for a bit I did come up with an approach to get this to work by supplying my own version of the update process.

Depends on what you’re updating. Using DBContext is just as dangerous as using SSMS and has all the same caveats: bypasses business rules (as you know) and security, SOX disclosure required if you’re a public US company, potential warranty issues with Epicor, …

1 Like