# Customized Panes for 'xxxxxxxx' Created: 2009/11/05
# PANE:Supplier Branch Notepad
[PANE]
ADMIN ARSPENLZ 01000Supplier Branch Notepad 060 000000500001ARSPEN000M110 0000 0000
[VBSCRIPT]
' This script contains functions for customized pane events.
' You must not modify the name of the functions.
Option Explicit
Function CustomizedPane_OnLoad()
CustomizedPane.CodeObject.GlobalVariable2 = ""
End Function
Function CustomizedPane_OnRefresh()
' Check if the contents of the notepad has changed since it was displayed, to work out if
' it must be saved.
If CustomizedPane.CodeObject.RTFChanged = "1" then
dim XMLOut, XMLParam
' Customized Pane Global Variable at this point contains the previous supplier branch code.
' Check if it is empty. If it is not empty the currently displayed notes must be written away before
' displaying those for the new supplier branch.
If CustomizedPane.CodeObject.GlobalVariable <> "" then
' Create variables for use in saving away the existing notes
dim XMLOut2, XMLParam2, XMLDoc2, fs2, fn2, MyContents2, MyContents3, Mylength2
' The current contents of the notepad are written to a temporary file on the client.
' The name of this temporary file is held in the varaiable RTFTextFileIn. Open this file
' and read in the contents to a variable called MyContents. Remove any Null characters that
' may appear in the temporary file. remove the trailing chariage return and line feed characters.
Set fs2 = CreateObject("Scripting.FileSystemObject")
Set fn2 = fs2.OpenTextFile(CustomizedPane.CodeObject.RTFTextFileIn)
MyContents2 = Replace(fn2.ReadAll, vbNullChar, "")
fn2.close
Set fn2 = nothing
Set fs2 = nothing
MyLength2 = Len(MyContents2)
MyContents3 = Left(MyContents2, Mylength2 -2)
' Build up the XML required to write the contents of the notepad away. At this point the Customized
' Pane Global Variable still contains the previous customers branch code.
XMLParam2 = XMLParam2 & " "
XMLDoc2 = XMLDoc2 & " "
XMLDoc2 = XMLDoc2 & " - "
XMLDoc2 = XMLDoc2 & " "
XMLDoc2 = XMLDoc2 & " " & SystemVariables.CodeObject.Company & ""
XMLDoc2 = XMLDoc2 & " SUPBRN"
XMLDoc2 = XMLDoc2 & " " & CustomizedPane.CodeObject.GlobalVariable & ""
XMLDoc2 = XMLDoc2 & " "
XMLDoc2 = XMLDoc2 & " "
XMLDoc2 = XMLDoc2 & "
"
XMLDoc2 = XMLDoc2 & " "
on error resume next
' Check to see if the notes were read in from COMNOT, or created from scratch.
If CustomizedPane.CodeObject.GlobalVariable2 = "Y" Then
' If the notes were read in from COMNOT, call the COMSNO business object and use
' the UPDATE method
XMLOut2 = CallSetup("COMSNO",XMLParam2,XMLDoc2,"Update","auto")
Else
' If the notes were not read in from COMNOT, call the COMSNO business object and
' use the ADD method
XMLOut2 = CallSetup("COMSNO",XMLParam2,XMLDoc2,"Add","auto")
End If
if err then
msgbox err.Description, vBCritical, "Calling Business Object"
exit function
end if
' Switch on error handling
on error goto 0
End If
End If
' The end of the section to save the notes related to the old supplier branch code.
' Start of the section to read in the notes for the new supplier branch code.
' Populate the Customized Pane Global Variable with the refresh value (the new supplier branch code).
CustomizedPane.CodeObject.GlobalVariable = CustomizedPane.CodeObject.RefreshValue
' Check to see if the Customized Pane Global Variable is empty, and exit the function if it is.
if CustomizedPane.CodeObject.GlobalVariable = "" then
exit function
end if
' Build up the XML required to invoke the COMNOT business object to see if notes exist for this supplier branch code.
' Note that this contains the new supplier branch code at this time.
XMLParam = XMLParam & " "
XMLParam = XMLParam & " "
XMLParam = XMLParam & " SUPBRN"
XMLParam = XMLParam & " " & CustomizedPane.CodeObject.GlobalVariable & ""
XMLParam = XMLParam & " "
XMLParam = XMLParam & " Y"
XMLParam = XMLParam & " "
on error resume next
' Call the COMNOT business object, and put the results in to XMLOut
XMLOut = CallBO("COMNOT",XMLParam,"auto")
' Switch on error handling
on error goto 0
' Check to see if XMLOut is empty.
If XMLOut = "" then
' If XMLOut is empty, set the Customized Pane Global Variable 2 to N. This is required when the
' notes are saved as you need to ADD them.
' The RTFText variable is cleared out so that the previous supplier branch notes do not appear.
CustomizedPane.CodeObject.GlobalVariable2 = "N"
CustomizedPane.CodeObject.RTFText = " "
Else
' If XMLOut is not empty, set the Customized Pane Global Variable 2 to Y. This is required when
' the notes are saved as you need to UPDATE them.
' The RTFText variable is populated with the contents of XMLOut so that the existing notes appear.
CustomizedPane.CodeObject.GlobalVariable2 = "Y"
CustomizedPane.CodeObject.RTFText = XMLOut
End If
End Function
Function CustomizedPane_OnSave()
' Check if the contents of the notepad has changed since it was displayed, to work out if
' it must be saved.
If CustomizedPane.CodeObject.RTFChanged = "1" then
' Create variables for use in saving away the existing notes
dim XMLOut, XMLParam, XMLDoc, fs, fn, MyContents, MyContents4, MyLength
' The current contents of the notepad are written to a temporary file on the client.
' The name of this temporary file is held in the varaiable RTFTextFileIn.
' Open this file and read in the contents to a variable called MyContents.
' Strip out any NULL characters, and the the trailing carriage return and line feed characters.
Set fs = CreateObject("Scripting.FileSystemObject")
Set fn = fs.OpenTextFile(CustomizedPane.CodeObject.RTFTextFileIn)
MyContents = Replace(fn.ReadAll, vbNullChar, "")
fn.close
Set fn = nothing
Set fs = nothing
MyLength = Len(MyContents)
MyContents4 = Left(MyContents, Mylength -2)
' Build up the XML required to write the contents of the notepad away.
XMLParam = XMLParam & " "
XMLDoc = XMLDoc & " "
XMLDoc = XMLDoc & " - "
XMLDoc = XMLDoc & " "
XMLDoc = XMLDoc & " " & SystemVariables.CodeObject.Company & ""
XMLDoc = XMLDoc & " SUPBRN"
XMLDoc = XMLDoc & " " & CustomizedPane.CodeObject.GlobalVariable & ""
XMLDoc = XMLDoc & " "
XMLDoc = XMLDoc & " "
XMLDoc = XMLDoc & "
"
XMLDoc = XMLDoc & " "
on error resume next
' Check to see if the notes were read in from COMNOT, or created from scratch.
If CustomizedPane.CodeObject.GlobalVariable2 = "Y" Then
' If the notes were read in from COMNOT, call the COMSNO business object and use
' the UPDATE method
XMLOut = CallSetup("COMSNO",XMLParam,XMLDoc,"Update","auto")
Else
' If the notes were not read in from COMNOT, call the COMSNO business object and
' use the ADD method
XMLOut = CallSetup("COMSNO",XMLParam,XMLDoc,"Add","auto")
End If
if err then
msgbox err.Description, vBCritical, "Calling Business Object"
exit function
End if
' Switch on error handling
on error goto 0
End If
End Function