Script to Update Module Date?

SOLVED

I am trying to determine if it's possible to update the A/R module's accounting date via script.

It appears that module dates are stored in the SY_ModuleDate table, but the table does not have an associated business object with it - to which I assume that this would then not be possible.

Any insight is appreciated

  • +1
    verified answer

    Greetings,

    Setting the module date in Sage 100 is handled through the session object SetDate method.  Here is a code snip that shows the instantiation of the session object and setting the module date for A/P to today's date.  This code uses the Sage Object Management NuGet package.

    using (dynamic pvx = new PvxDynamic("ProvideX.Script"))
    {
        pvx.Init(@"C:\2022\MAS90\Home");
        using (dynamic sySession = pvx.NewObject("SY_Session"))
    {
        int result = sySession.nLogon();
        if (result == 0)
        {
            result = sySession.nSetUser("User", "Password");
            if (result == 0) throw new Exception(sySession.sLastErrorMsg);
        }

        result = sySession.nSetCompany("ABC");
        if (result == 0) throw new Exception(sySession.sLastErrorMsg);

        result = sySession.nSetDate("A/P", "11222023");
        if (result == 0) throw new Exception(sySession.sLastErrorMsg);

        result = sySession.nSetModule("A/P");
        if (result == 0) throw new Exception(sySession.sLastErrorMsg);

    }

    Thanks,
    Kent