BOI won't get past prompt message

SOLVED

I am using BOI to programmatically create AR invoices.  I am having an issue if MAS prompts a pop up message if the invoice numbers has been used before and needs to be overridden.  How can I answer "YES" to the prompt programmatically and continue creating the AR Invoice through BOI?

Thank you,

  • 0

    Greetings,

    You shouldn't be getting a prompt when using the business object. I am concerned that there could be an issue with the business logic if it isn't an problem wiht your script.  Would you please post your BOI script (removing any confidential information) so that we can see the logic you are using to create the invoices?

    Thank you,

    Kent

  • 0 in reply to Kent Mackall

    Here is the part of the code that is failing.  When I set the key value for the invoice number, I'm expecting a 0, 1, or 2.  Instead, I get returned a -1 and the last error msg reads the message of the prompt.

    "Invoice number already used.  Would you like to accept?"

    retVAL = AR_Invoice_bus.nSetKeyValue("InvoiceNo$", InvoiceNumber)

    If retval <= 0 Then

               ErrorString += ErrMsg

    End If

    How do I answer the prompt so I can continue setting the rest of the values in the invoice?

  • 0 in reply to nsaia

    Greetings,

    Now I understand what is happening.  Once you update an invoice to history, that number is considered to have been used.  When you do the SetKeyValue of an invoice number that is already in history, we do return a -1 return value and put a warning message in LastErrorMsg but no UI prompt actually displays.  

    It is up to you to determine how to handle this return value of -1 in your script.  If you don't care about reusing an already used Invoice Number then bypass that warning and continue to set the key value for InvoiceType and then call SetKey() to create the Invoice.

    If you don't want users to resuse already used InvoiceNumbers, then either prompt the user and/or add logic in your script to handle this and increment to the next invoice number.

    Thanks,

    Kent

  • 0 in reply to Kent Mackall

    Thank you. unfortunately, I do not have the luxury of allowing the users to respond to the prompt as I am programming this as a web service and therefore have no UI. I know that when the BOI response returns a -1 I am getting a prompt and will handle that exception in the code. But when I send the next command in the sequence to set the value of the 'invoice type", it returns with a failure (0) because it's still waiting for the prompt to be answered first before continuing. Since I have no UI to click on to answer the prompt, how can I accept 'Yes' to the prompt using BOI and continue on to set the invoice type value?

  • 0 in reply to nsaia
    verified answer

    Greetings,

    It should not be waiting on a reponse.  The warning is just that, a warning.  It should allow you to proceed.  I was able to set the Invoice Type and do the SetKey() in my test after using an already used invoice number.

    Thanks,

    Kent

  • 0 in reply to Kent Mackall

    Here is the script I used to test in ABC Demo Data with Batch entry turned off for A/R Invoice Entry.  Also, I had created and updated Invoice # 0100057 prior to running this.  As you can see, it does allow creation of a new invoice using a previously used Invoice Number.

    This is not production code and it stops after the SetKey().

    Set oScript = CreateObject ("ProvideX.Script")

    oScript.Init("C:\Sage\Sage 100 Standard ERP\MAS90\Home")

    Set oSS = oScript.NewObject("SY_Session")

    retVAL = oss.nlogon()

    If retVAL = 0 Then

    User = Trim(InputBox("Enter User Name"))

    Password = Trim(InputBox("Enter Password"))

    retVAL = oSS.nSetUser(User,Password)

    End If

    If retVAL = 0 Then

    MsgBox(oSS.sLastErrorMsg)

    oSS.nCleanup()

    oSS.DropObject()

    Set oSS = Nothing

    WScript.Quit

    End If

    retVAL = oSS.nSetCompany("ABC")

    If retVAL = 0 Then

    MsgBox(oSS.sLastErrorMsg)

    oSS.nCleanup()

    oSS.DropObject()

    Set oSS = Nothing

    WScript.Quit

    End If

    retVAL = oSS.nSetDate("A/R","20150429")

    If retVAL = 0 Then

    MsgBox("SetDate Failed - " & oSS.sLastErrorMsg)

    Else

    retVAL = oSS.nSetModule("G/L")

    If retVAL = 0 Then

    MsgBox("SetModule Failed - " & oSS.sLastErrorMsg)

    End If

    End If

    retVAL = oSS.nSetProgram(oSS.nLookupTask("AR_Invoice_ui"))

    Set oARINVBUS = oScript.NewObject("AR_Invoice_bus", oSS)

    ' Set Key Values for already used Invoice

    retVal = oARINVBUS.nSetKeyValue("InvoiceNo$","0100057")

    MsgBox cSTR(retVal) ' this will be -1 since 0100057 was already update to history

    retVal = oARINVBUS.nSetKeyValue("InvoiceType$","IN")

    MsgBox cSTR(retVal) ' this will be 1 or success

    retVal = oARINVBUS.nSetKey()

    MsgBox cStr(retVal) 'this will be 2 or new record

  • 0 in reply to Kent Mackall

    Let me test this process on my end.  I'll get back to you.  Thank you for the suggestion.

  • 0 in reply to Kent Mackall

    Thank you, Kent!

    Well now i'm just embarrassed! I had the code set up just fine to run the next set value command, but my error handling was catching everything <= 0. Since the prompt was returning a -1, I was telling my code to handle anything below 0 as an error.  You shed some light on this as you made me realize that -1 in this case is just a warning and that I could ignore it and continue on.

    I have made the necessary adjustments in my error handling and everything continued on just fine. Thank you for your help.