After writing card values through script, revision table not showing new values

I’m trying to update datacard values so it will reflect in my revision table.
this test code doesn’t change the datacard even though GetVarFromDb shows the right value.

    public void TestDataCard()
    {
        FileInfo file = new FileInfo(@"C:\PDM_VAULT\Test 1\Test mbs drawing.SLDDRW");

        pdmFile = _vault.GetFileFromPath(file.FullName, out retFolder);
        swEnumeratorVariable = pdmFile.GetEnumeratorVariable();
        swEnumeratorVariable.SetVar(DataCardFields.RevTeable_Revision, "@", "04");
        swEnumeratorVariable.Flush();
        swEnumeratorVariable.SetVar(DataCardFields.RevTeable_Description, "@", "testing");
        swEnumeratorVariable.Flush();
        IEdmEnumeratorVariable6 evars2 = swEnumeratorVariable as IEdmEnumeratorVariable6;
        evars2.GetVarFromDb(DataCardFields.RevTeable_Revision, "@", out object retValue);
        evars2.GetVarFromDb(DataCardFields.RevTeable_Description, "@", out object retValue2);
        Evars = swEnumeratorVariable as IEdmEnumeratorVariable10;
        Evars.CloseFile(true);    
    }

longer story, if I’m writing the values the way I usually do (iterate through all configurations and changing), it reflects the change in the datacard, but not in the revision table (I also see all values in all revisions when checked in, but if I check out “@” configuration is empty). if I change the value manually everything works

this is the longer code:

public void IterateDataCard(FileInfo file)
{
swEnumeratorVariable = default(IEdmEnumeratorVariable5);
retFolder = default(IEdmFolder5);
cfgList = default(EdmStrLst5);
pos = default(IEdmPos5);
pdmFile = _vault.GetFileFromPath(file.FullName, out retFolder);
swEnumeratorVariable = pdmFile.GetEnumeratorVariable();
cfgList = pdmFile.GetConfigurations();
pos = cfgList.GetHeadPosition();
}

public void WriteDataCard(FileInfo file, string variableName, string newValue = null) // TODO: do all changes in one loop and then flush
{
IterateDataCard(file);

Vault vault = new Vault();
pdmFile = _vault.GetFileFromPath(file.FullName, out retFolder);

(string pnString, string descString) = vault.FilenameToDataCard(file);

while (!pos.IsNull)
{
    swEnumeratorVariable = pdmFile.GetEnumeratorVariable();
    cfgName = cfgList.GetNext(pos);
    object value;
    
    if (variableName == DataCardFields.Material)
    {
        swEnumeratorVariable.SetVar(variableName, cfgName, null, true);
    }

    if (variableName == DataCardFields.PartNo)
    {
        newValue = pnString;
    }

    if (variableName == DataCardFields.Description)
    {
        newValue = descString;
    }

    if (variableName == DataCardFields.DESIGN)
    {
        //newValue = vault.GetCurrentDesigner();
        newValue = "user"; //TODO CHANGE!!!!!
    }

    if (variableName == DataCardFields.ProjectNumber || variableName == DataCardFields.Project)
    {
        string path = Path.GetDirectoryName(file.FullName);

        // Normalize path and split into parts
        string normalizedPath = Path.GetFullPath(path);
        string[] parts = normalizedPath.Split(Path.DirectorySeparatorChar);

        // Find "PDM_VAULT" and get the next folder
        for (int i = 0; i < parts.Length; i++)
        {
            if (parts[i].Equals("PDM_VAULT", StringComparison.OrdinalIgnoreCase) && i + 1 < parts.Length)
            {
                string targetFolder = parts[i + 1];

                // Extract Project number and project name using regex
                Match match = Regex.Match(targetFolder, @"(.*?)\s*-\s*(.*)");
                if (match.Success)
                {
                    string projectNumber = match.Groups[1].Value.Trim();
                    string projectName = match.Groups[2].Value.Trim();

                    if (variableName == DataCardFields.ProjectNumber)
                    {
                        newValue = projectNumber;
                    }

                    if (variableName == DataCardFields.Project)
                    {
                        newValue = projectName;
                    }
                }
                else
                {
                    Debug.WriteLine("Pattern not found.");
                }
                break;
            }
        }
    }

    try
    {
        //Debug.WriteLine($"Checked out by: {pdmFile.LockedByUserID}");
        pdmFile.Refresh();
        if (!pdmFile.IsLocked)
        {
            pdmFile.LockFile(retFolder.ID, 0);
            //Debug.WriteLine($"Checked out by: {pdmFile.LockedByUserID}");
        }
        IsReadable(file);
        IsWritable(file);
        //swEnumeratorVariable.SetVar(DataCardFields.RevTeable_Revision, "@", "04", true);
        //swEnumeratorVariable.SetVar(DataCardFields.RevTeable_Description, "@", "testing", true);
        swEnumeratorVariable.SetVar(variableName, cfgName, newValue, true);
        IEdmEnumeratorVariable8 swEnumeratorVariable2 = (IEdmEnumeratorVariable8)swEnumeratorVariable;
        swEnumeratorVariable2.CloseFile(true);
        //pdmFile.UnlockFile(0, "Updated Datacard");
    }
    catch (System.Runtime.InteropServices.COMException ex)
    {
        MessageBox.Show("HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message);
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }

    //if (variableName == DataCardFields.Revision)
    //{
    //IEdmFile13 pdmFile = (IEdmFile13)_vault.GetFileFromPath(file.FullName, out retFolder);
    //Workflow wf = new Workflow();
    //wf.StartWorkflow(pdmFile, retFolder, "Legacy Revision", "ECO Design");
    //}
    
    Debug.WriteLine($"In Configuration {cfgName}, Variable '{variableName}': is now {this.ReadDataCard(file, variableName)}");
}
IEdmEnumeratorVariable8 swEnumeratorVariable1 = (IEdmEnumeratorVariable8)swEnumeratorVariable;
swEnumeratorVariable1.CloseFile(true);
//pdmFile.UnlockFile(0, "Updated Datacard");

}

Now I tried IEdmBatchUpdate2, “@” not getting updated either

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using EPDM.Interop.epdm;

namespace Macros.Classes
{
public class DataCardBatchUpdate
{
private IEdmVault7 _vault;
public DataCardBatchUpdate()
{
Vault vault = new Vault();
_vault = vault.GetVault();
}

    public void UpdateDataCardValues(List<string> filePaths)
    {
        try
        {
            if (!_vault.IsLoggedIn)
            {
                throw new Exception("Not logged into the vault.");
            }

            IEdmBatchUpdate2 batchUpdate = (IEdmBatchUpdate2)_vault.CreateUtility(EdmUtility.EdmUtil_BatchUpdate);

            //Get the IDs of the file and folder card variables to update
            int RevRevisionID = 0; //49
            int RevDescriptionID = 0; //56
            IEdmVariableMgr5 VariableMgr = default;

            VariableMgr = (IEdmVariableMgr5)_vault;
            RevRevisionID = VariableMgr.GetVariable("Rev_Revision").ID;
            RevDescriptionID = VariableMgr.GetVariable("Rev_Description").ID;

            foreach (var filePath in filePaths)
            {
                IEdmFile5 file = _vault.GetFileFromPath(filePath, out IEdmFolder5 folder);
                if (file != null)
                {
                    batchUpdate.SetVar(file.ID, RevRevisionID, "04", "", (int)EdmBatchFlags.EdmBatch_AllConfigs);
                    batchUpdate.SetVar(file.ID, RevDescriptionID, "Test Description", "", (int)EdmBatchFlags.EdmBatch_AllConfigs);
                }
                else
                {
                    Console.WriteLine($"File not found: {filePath}");
                }
            }

            //Write all the card variable values to the database
            EdmBatchError2[] Errors = null;
            int errorSize = 0;
            errorSize = batchUpdate.CommitUpdate(out Errors, null);

            //Display any errors 
            Debug.WriteLine("Datacards Updated");
        }

        catch (System.Runtime.InteropServices.COMException ex)

        {

            MessageBox.Show("HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message);

        }

        catch (Exception ex)

        {

            MessageBox.Show(ex.Message);

        }
    }

}

}

You’re supposed to use swEnumeratorVariable.Flush(); or CloseFile only once after you edited all your variables. Once done, the object is useless and you should get a new instance to make further changes. I’d call IEdmFile.Refresh to refresh my file before validating if my values got stored.