This example shows you how to setup a script to:
Looking back at the first script we wrote in Script to Create a New Invoice, we can now look at taking that concept a few steps further. For example we could:
Dim frmINInvoice1 as Object
frmINInvoice1 = CreateObject("Accredo.INInvoiceEntryForm")
frmINInvoice1.InsertInvoice
Dim frmINInvoice1 as Object
frmINInvoice1 = GetActiveObject
If IsNull(frmINInvoice1) Or frmINInvoice1.ClassName <> "INInvoiceEntryForm" Then ' Can we reuse the current form
frmINInvoice1 = CreateObject("Accredo.INInvoiceEntryForm") 'f not open a new one
ElseIf frmINInvoice1.ClassName = "INInvoiceEntryForm" And frmINInvoice1.Editing Then
Error "Current Invoice is being edited, Insert cancelled, please save changes and re-try."
End If
frmINInvoice1.InsertInvoice
Dim frmINInvoice1 as Object
frmINInvoice1 = GetActiveObject
If IsNull(frmINInvoice1) Or frmINInvoice1.ClassName <> "INInvoiceEntryForm" Then ' Can we reuse the current form
frmINInvoice1 = CreateObject("Accredo.INInvoiceEntryForm") 'f not open a new one
ElseIf frmINInvoice1.ClassName = "INInvoiceEntryForm" And frmINInvoice1.Editing Then
Error "Current Invoice is being edited, Insert cancelled, please save changes and re-try."
End If
frmINInvoice1.InsertInvoice
Customer = InputCode("ARCUST", "Customer code", "Customer")
If IsNull(Customer) Then Error "Cancelled by User"
frmINInvoice1.CustomerCode = Customer
frmINInvoice1.InternalReference = LoginUserName
frmINInvoice1.Comment = Time & " " & Date
Dim frmINInvoice1 as Object
frmINInvoice1 = GetActiveObject
If IsNull(frmINInvoice1) Or frmINInvoice1.ClassName <> "INInvoiceEntryForm" Then ' Can we reuse the current form
frmINInvoice1 = CreateObject("Accredo.INInvoiceEntryForm") 'f not open a new one
ElseIf frmINInvoice1.ClassName = "INInvoiceEntryForm" And frmINInvoice1.Editing Then
Error "Current Invoice is being edited, Insert cancelled, please save changes and re-try."
End If
frmINInvoice1.InsertInvoice
Customer = InputCode("ARCUST", "Customer code", "Customer")
If IsNull(Customer) Then Error "Cancelled by User"
frmINInvoice1.CustomerCode = Customer
frmINInvoice1.InternalReference = LoginUserName
frmINInvoice1.Comment = Time & " " & Date
frmINInvoice1.Line.Append