Previous Topic

Next Topic

Book Contents

Book Index

Extend Start New Invoice Script

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:

  1. Open the NewInvoice1.pfs script.

    Dim frmINInvoice1 as Object

    frmINInvoice1 = CreateObject("Accredo.INInvoiceEntryForm")

    frmINInvoice1.InsertInvoice

  2. Add code to check if the Invoice Entry form is already open, and make sure an invoice is not currently being edited.

    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

  3. Add code to auto-fill in some of the header information:

    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

  4. Add code to take the user to the Invoice lines:

    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