Function runs on one system but not the other

Our company has 2 locations and each runs their own version of Epicor. We are currently both on 2024.2.100 and our servers on on the same version (I don’t know which because I just do the Epicor end). I have a function that works in one system but not the other. Everything is exactly the same inside the function setup.

The function errors at Db.SaveChanges in one system. If I remove that line it runs but doesn’t updates the fields.

Working Function:

string lastPart = null;

var resultsTable = baqResults.Tables["Results"];

foreach (System.Data.DataRow row in resultsTable.Rows)
{
    var partNum = row["Part2_PartNum"].ToString().Trim();  // trim to prevent mismatch
    var goNegDate = row["Calculated_GoNegMain"] as DateTime?;
    var updatedDate = row["Calculated_UpdatedDate"] as DateTime?;

    var part = Db.Part.FirstOrDefault(p => p.PartNum == partNum);
    if (part != null)
    {
        part.GoNegDate_c = goNegDate;
        part.GoNegUpdated_c = updatedDate;
        updatedCount++;
        lastPart = partNum;
    }
}

Db.SaveChanges();

// Push results into function outputs
UpdatedCout = updatedCount;
LastPartNum = lastPart ?? "None updated";

Error when adding Db.SaveChanges();

System.Drawing.Bitmap CS1061 'ILibraryContext' does not contain a definition for 'SaveChanges' 
and no accessible extension method 'SaveChanges' accepting a first argument of type 'ILibraryContext' could be found 
(are you missing a using directive or an assembly reference?)
1 Like

In References - Tables, you need to check “Updatable” on the Part table. Db.SaveChanges() will only show up/function if at least one table is marked updatable. It will only allow updates to tables marked updatable.

4 Likes

Thank you so much - was banging my head on this for a week. Once the function is in Production that checkbox goes away - and it wasn’t visible in edit mode until I expanded the screen :woman_facepalming: