Copying the Date value into new date UDF on the Invoice Data Entry

SOLVED

Hi 

We have a requirement, where when a new invoice is getting entered in AP, using a VBScript copy the Invoice Date to a new UDF.

I did try to put the same using the Post Validate event on the Invoice Date, but it's not copying the data into the new UDF field. 

Anybody came across similar requirements, please share their findings/logic or any other solution approach. 

Script 1 - with Message box confirmation works fine 

If oSession.CompanyCode="TST" Then

                 'Declare Variables

                dInvoiceDate = ""

                dVendorInvDate = ""

                sMsg = ""

                 If oBusObj.EditState = 2 Then

                                'get values

                                retval = oBusObj.GetValue("InvoiceDate$", dInvoiceDate)

                                retval = oScript.DebugPrint("The value of the Invoice Date is: " + dInvoiceDate)            

                                If dVendorInvDate = "" Then

                               sMsg = "The Invoice Date is " + dInvoiceDate +". Would you like to retain the same as the Vendor Invoice date"

                                Set oUI = oSession.AsObject(oSession.UI)

                                retMsg = oUI.MessageBox(".Y2", sMsg)

 

                                                If retMsg = "YES" Then

                                                'retval = oScript.DebugPrint("The user clicked yes")

                                                retval =oBusObj.SetValue("UDF_Vendor_Invoice_DATE$",dInvoiceDate)

                                                retval = oBusObj.SetValue("UDF_Vendor_Invoice_DATE$",dInvoiceDate)

                                                Else

                                                'retval = oScript.DebugPrint("The user clicked No")

                                                retval =oBusObj.SetValue("UDF_Vendor_Invoice_DATE$",dVendorInvDate)

                                                End If

                                End If

                End If

End If

Script 2 - without Message box confirmation does not work.

If oSession.CompanyCode="TST" Then
 'Declare Variables
 dInvoiceDate = ""
 dVendorInvDate = ""
  
 If oBusObj.EditState = 2 Then
  'get values
  retval = oBusObj.GetValue("InvoiceDate$", dInvoiceDate)
  retval = oScript.DebugPrint("The value of the Invoice Date is: " + dInvoiceDate)
 
  If dInvoiceDate <> "" Then
  retval = oBusObj.SetValue("UDF_Vendor_Invoice_DATE$", dInvoiceDate)
  Else
  retval = oBusObj.SetValue("UDF_Vendor_Invoice_DATE$",dVendorInvDate)
  End If
End If
End If

Also, is there a way to capture the sysdate for the new UDF date field. Please advise and recommend.

Thanks

AJ

Parents
  • +1
    verified answer

    Use the trace window or display a message box to verify the script is even firing.

    Check the scripts syntax to make sure it is free of errors, if a syntax error exists, the script will fail to execute silently.

    The post validate event might not be firing when the default value is placed in the invoice date field when a new invoice is created, so since you are checking the EditState property, you may need to also attach your script to the header table's post read event.

Reply
  • +1
    verified answer

    Use the trace window or display a message box to verify the script is even firing.

    Check the scripts syntax to make sure it is free of errors, if a syntax error exists, the script will fail to execute silently.

    The post validate event might not be firing when the default value is placed in the invoice date field when a new invoice is created, so since you are checking the EditState property, you may need to also attach your script to the header table's post read event.

Children