After much research I have gotten this code to work. I need to experiment more to stop the print dialog box popping up.
public static bool PostBatch(string batchNumber)
{
//clear posting destid's array.
string[] DestID = new string[] { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" };
string BatchSource = "GL_Normal"; /* BATCH_SOURCE_GL_ENTRY */
Int16 nWindowType = 2; /* BATCH_WINDOW */
Int16 nActivityType = 2; /* SY_BA_EDITLIST = 3, SY_BA_POSTING = 2 */
bool EditList = false;
//inout nStatus in posting call
Microsoft.Dexterity.Bridge.Field<short> nStatus = new Field<short>(0);
Field<string> reportDestination = new Field<string>("");
Microsoft.Dexterity.Applications.Dynamics.Procedures.PostingRptDestWdw.Invoke("", "GENERAL POSTING JOURNAL", "GENERAL POSTING JOURNAL", "GENERAL POSTING JOURNAL", 3, ref reportDestination);
DestID[0] = reportDestination.Value; /* copy our read/write destid from above to our array */
//Initialize it with our array above
FieldArray<string> DestIDArray = DestID;
//for GL Posting, there is 1 report.
//Send reports to screen only
DestID[0] = String.Format("TF{0}{1}{2}{3}{4}", "T", "F", "F", ((int)FILEOUTPUT.NONE).ToString().PadLeft(4).ToString(), "");
//Dynamics.Forms.Batch.Procedures.Post.Invoke(BatchSource, batchNumber, nWindowType, nActivityType, DestID, ref nStatus); /* call posting, edit list routine */
//Dynamics.Forms.GlBatchEntry.Procedures.PostBatch.Invoke(EditList, nWindowType, batchNumber, BatchSource, DestID, ref nStatus);
Dynamics.Forms.GlBatchEntry.Procedures.PostBatch.Invoke(EditList, nWindowType, batchNumber, BatchSource, DestID);
if (nStatus != 0)
{
MessageBox.Show("Posting failed");
}
return true;
}