BOI - unable to get value with nGetNextJournalNo and can't set key

SOLVED

I am writing a C# app to bring in Journal Entries.  I have two issues; I am getting no value for nGetNextJournalNo and I get an invalid key error when attempting to set the SourceJournal+EntryNo key, even though I am setting entryno to a string.  I have also tried hard-coding the key instead of trying to get the next number and still got an invalid error.

gl_bus is GL_GeneralJournal_bus

gl_svc is GL_SourceJournal_svc

gl_bus.InvokeMethod("nSetKeyValue", "SourceJournal$", "AP");
gl_svc.InvokeMethod("nGetNextJournalNo", "AP", journalEntryNo);
gl_bus.InvokeMethod("nSetKeyValue", "EntryNo$", journalEntryNo);
gl_bus.InvokeMethod("nSetKey");

  • 0

    Hi ,

    Did you try typing the journal Entry No?  Also, you can use the business object to make that call. So you wouldn't need the GL_SourceJournal_svc, but either way it's the same call.

    sJournalEntryNo = "";

    gl_bus.InvokeMethod("nGetNextJournalNo", "AP", sJournalEntryNo);

    Hope that helps

    Elliott

  • 0 in reply to jepritch

    Thanks for the response, Elliott!

    I had to use nGetNextEntryNo, since nGetNextJournalNo is not available using the busness object, but I am still returning an empty string.  I have also tried setting the key with manually entered strings for both, and I am getting an error with that.  I have to be missing something goofy.  I am hoping that it will hit me today.  I gave up on it yesterday and am hoping that I will see something obvious now that I have slept on it.  If/when I find the solution, I will post it.  Btw, I tried setting the key this way:

    gl_bus.InvokeMethod("nSetKey", "AP123456") and the sLastErrorMsg is "The AP123456 is invalid."  I can't figure out why, I haven't used that entry number in my test system before.  I have tried the same idea with multiple source journals and entry numbers witht the same error.  My application fails with an obvious invalid header at that point.  Hmmmm.....

    It may also be worth noting that we are using batches.  I am setting a new batch before the code above.  It creates the batch fine, but bombs out on the nextentryno or setkey.

  • 0 in reply to willHyland

    I would suggest checking the index (you will have to translate my code to C#)

    index = oBusObj.sCurrentIndex

    index should be "kPRIMARY" or "kBATCH"

    from the File layouts

    KPRIMARY: SourceJournal+EntryNo

    KBATCH: BatchNo+SourceJournal+EntryNo

    I am guessing that you need to add

    retVal = nSetIndex("kPRIMARY")

    or

    retVal = nSetKeyValue("BatchNo$", batch)

  • 0 in reply to dlech

    Thanks again for the response.  I can translate from VBS or VB.NET so that is not a problem.  I'll try your suggestion and play around with the index to see if I can get something going.  I will let you know if I figure it out.  The strange thing is that I set up a similar job for invoice data entry and that was a batch process as well.  I didn't have to change the index, I just had to use nSelectBatch/nSelectNewBatch before I set my keys.  I am incredibly confused!

  • 0 in reply to willHyland

    I am a dork!  The error I was getting when setting the key is thrown every time I am creating a new record.  It was not causing any kind of an issue.  I am still not able to get the next journal number, but I will post when I figure that out.

  • 0 in reply to willHyland

    I am starting to think that I won't be able to achieve this with C#.  I wrote a quick vb script and it worked using nGetNextEntryNo and GetNextJournalNo.  It seems like it has a problem filling the empty string wtih the value in C#.  I know it is successful because I am returning 1 for the retVal.  If anyone finds an answer for this, let me know.

  • 0 in reply to willHyland

    Since this is C#, wouldn't you have to use the ref keyword on the method parameters that return a value?

    As in...

    gl_svc.InvokeMethod("nGetNextJournalNo", "AP", ref journalEntryNo);

  • 0 in reply to dlech

    This ^ did not work.  Do I need extra code above that?  I am getting the following error:

    Argument 3: cannot convert from 'ref string' to 'object'

  • 0 in reply to willHyland

    dlech helped me get on the right direction.  Here is what I had to do:

    object[] oNextEntry = new object[] { "AP", "EntryNo$" };

    gl_bus.InvokeMethodByRef("nGetNextEntryNo", oNextEntry);

    MessageBox.Show(oNextEntry[1].ToString());

  • 0 in reply to willHyland
    verified answer

    object[] oNextEntry = new object[] { "AP", "EntryNo$" };

    gl_bus.InvokeMethodByRef("nGetNextEntryNo", oNextEntry);

    sJournalEntryNo = oNextEntry[1].ToString();