dotNet API PROCESSCMD

Sage 300 dotNet API project. Lots of the available docs say to use create a macro in the UI for what you want to do and then translate to C#. Works great for most of it but I am having an issue with the PROCESSCMD lines, which are often necessary to get optional fields that are set to automatically populate to actually have that happen.
Macro line is
ARCUSTOMER3headerFields("PROCESSCMD").PutWithoutVerification ("0")

C# translation is
ARCUSTOMER3headerFields("PROCESSCMD").PutWithoutVerification("0");
but Visual studio says: "Error CS1955 Non-invocable member 'ARCUSTOMER3headerFields' cannot be used like a method."

Anyone know how to work around this?

Parents Reply Children
  • 0 in reply to Jay Converse Acumen

    with the brackets around "PROCESSCMD" I get squiggles under the part up to the period

    CS0021 Cannot apply indexing with [] to an expression of type 'method group'

    With parentheses around "PROCESSCMD" I get squiggles under the part after the period 

    'ViewField' does not contain a definition for 'PutWithoutVerification' and no extension method 'PutWithoutVerification' accepting a first argument of type 'ViewField' could be found (are you missing a using directive or an assembly reference?)

  • 0 in reply to PhilMcIntosh

    public static AccpacView OEOrderDetail;  

    .Fields, not OEOrderDetailfields

  • 0 in reply to Jay Converse Acumen

    prior lines from my actual code:

    private ACCPAC.Advantage.View arCus;

    ...

    arCus = mDBLinkCmpRW.OpenView("AR0024");

    arCusOpt = mDBLinkCmpRW.OpenView("AR0400");
    arCus.Compose(new ACCPAC.Advantage.View[] { arCusOpt });
    arCusOpt.Compose (new ACCPAC.Advantage.View[] { arCus });

    ...

    arCus.RecordCreate(ViewRecordCreate.DelayKey);

    ...

    arCus.Fields.FieldByName["PROCESSCMD"].PutWithoutVerification("1");

  • 0 in reply to PhilMcIntosh

    Use the AccpacCOMAPI library, not the XAPI library.

  • 0 in reply to Jay Converse Acumen

    Jay,

    Thanks!  It works using COM instead Accpac Advantage.

    Is there a way to get it to autopopulate the default optional fields but still record specific optional field values?

    If PROCESSCMD is after setting the optional fields it overwrites them, and if it is before then calling arCusOpt.Insert() or Update() throws an error.  I suppose I could skip the optional fields on the insert routine and then pass the json file over to an update routine, but that feels rather wasteful.

    Phil

  • 0 in reply to PhilMcIntosh

    I handle all my optionals like this:

    static bool AddOrderOpt(string sOptfield, string sValue)
    {
    try
    {
    // Assumes that ArCustomerOpt as been composed
    OEOrderOptional.Fields.FieldByName["optfield"].PutWithoutVerification(sOptfield);
    if (OEOrderOptional.Read())
    {
    OEOrderOptional.Fields.FieldByName["value"].PutWithoutVerification(sValue);
    OEOrderOptional.Update();
    }
    else
    {
    OEOrderOptional.RecordGenerate(false);
    OEOrderOptional.Fields.FieldByName["OPTFIELD"].PutWithoutVerification(sOptfield);
    OEOrderOptional.Fields.FieldByName["value"].PutWithoutVerification(sValue);
    OEOrderOptional.Insert();
    }
    }
    catch
    {
    HandleError("AddCustomerOpt", "");
    return false;
    }
    return true;
    }