Click or drag to resize

Code Examples Attachment and Lookup supporting culture

Examples of code supporting cultures.

Examples

Example of code for adding attachment supporting cultures.

VB
  1    ' Imports SDK2011 = [Project Name].schemas.appliedsystems.com.epic.sdk._2011._01
  2    ' Imports SDK2009 = [Project Name].schemas.appliedsystems.com.epic.sdk._2009._07
  3
  4    ' Constant DATABASE preset to current database name
  5    ' Constant AUTHENTICATION_KEY set to current authentication key
  6    ' Constant USER_CODE set to a valid login user code
  7    Try
  8        Dim oService As New EpicSDK_2019_01Client ' Instantiate the Service object
  9        Dim oHeader As New SDK2009_07.MessageHeader ' Instantiate the Header object
 10
 11        Dim oClient As New EpicSDK_2019_01Client("ServiceBinding_2016_01")
 12        Dim oStreamingClient As New EpicSDKFileTransferClient("FileTransferServiceBinding")
 13
 14  ' Populate the database and authentication key in the Header object
 15  'REQUIRED
 16  oHeader.DatabaseName = DATABASE
 17  oHeader.AuthenticationKey = AUTHENTICATION_KEY
 18  'OPTIONAL
 19  oHeader.UserCode = USER_CODE
 20  oHeader.IntegrationKey = "eaa8b2df-94c0-4bac-a403-1a1b749b8e06" 'In this case we are identifing as the 3rd custom integration
 21  oHeader.Culture = CultureCode                                   'Example fr-CA
 22
 23  'Get lookup in french
 24  Dim oLookupResult As List(Of SDK2009._common.Lookup)  ' Instantiate the ResultObject
 25  Dim asArgs As New List(Of String)
 26  oLookupResult = oClient.Get_Lookup(p_oHeader, schemas.appliedsystems.com.epic.sdk._2009._07._common._lookup.LookupTypes.AttachmentFolder, asArgs)
 27  Dim sFolder = oLookupResult.Item(4).Description.ToString  'get Lookup description(in french) for the folder to which attachment is to be added
 28
 29  asArgs.Add(sFolder)                 ' specify the name of the folder in the search terms to get the name of the sub folder(again the results are returned in French).
 30
 31  ' Perform the lookup call
 32  oLookupResult = oClient.Get_Lookup(p_oHeader, schemas.appliedsystems.com.epic.sdk._2009._07._common._lookup.LookupTypes.AttachmentFolder, asArgs)
 33
 34  Dim sSubFolder As String = oLookupResult.Item(0).Description.ToString   'name of sub folder returned in French
 35
 36
 37  Dim sFilePath As String = "C:\Users\gkaur\Desktop\DBPhoto.docx" 'Provide the path and file name of file 
 38  Dim oFileInfo As New System.IO.FileInfo(sFilePath)              'Use class FileInfo to instantiate oFileInfo object
 39  Dim iFileLength As Integer = CInt(oFileInfo.Length)             'FileInfo.Length property gets the size of the file in bytes
 40
 41  'Load file data to a stream that can be passed to the server.
 42  Dim abFileData(iFileLength - 1) As Byte
 43  Dim rdrFile As System.IO.FileStream = oFileInfo.OpenRead        'FileInfo.OpenRead creates a read-only FileStream
 44  rdrFile.Read(abFileData, 0, iFileLength)                        'The Read method of the FileStream class reads a block of bytes from the stream. (abFileData=the actual number of bytes read or ‘zero if the end of the stream is reached, 0=the offset of the byte in array at which to begin reading, iFileLength=number of bytes ‘to be read) 
 45  Dim memStream As New IO.MemoryStream(abFileData)                'The MemoryStream class creates a stream whose backing store is memory
 46  rdrFile.Close()                                                 'Filestream.Close method closes the file stream
 47
 48  Dim oFileDetail As New SDK2009._account._attachment.FileDetailItem
 49
 50  'This actually uploads the file.  The returned string is used by SDK to 
 51  'identify the uploaded file on the SDK server.
 52  oFileDetail.TicketName = p_oStreamingClient.Upload_Attachment_File(p_oHeader, memStream)
 53  oFileDetail.Extension = oFileInfo.Extension                                       'FileInfo.Extension property gets the file extension
 54  oFileDetail.Length = iFileLength                                                  'FileInfo.Length property gets the length
 55  oFileDetail.FileName = oFileInfo.Name                                             'FileInfo.FileName gets the file name
 56
 57  Dim oAttachedTos As New SDK2009._account._attachment.AttachedToItems
 58  Dim oAttachedToItem As New SDK2009._account._attachment.AttachedToItem
 59
 60  With oAttachedToItem
 61    .AttachedToID = 65538
 62    'This value can be found using the lookup method(AttachmentAttachedTo)
 63    .AttachedToType = "Compte"      ' French translation of Account
 64  End With
 65
 66  oAttachedTos.Add(oAttachedToItem)
 67
 68  Dim oAttachFiles As New SDK2009._account._attachment.FileDetailItems
 69  oAttachFiles.Add(oFileDetail)
 70
 71  'Set the details of the attachment object
 72  Dim oAttachment As SDK2009._account.Attachment = New SDK2009._account.Attachment
 73  With oAttachment
 74
 75    .AccountID = 65538
 76    .Files = oAttachFiles
 77    .AttachedTos = oAttachedTos
 78
 79    .Description = oFileInfo.Name
 80    ''These values can be found using the lookup method(AttachmentFolder)
 81    .Folder = sFolder
 82    .SubFolder1 = sSubFolder
 83    '.ReceivedDate = New Date(2010, 12, 12) 'Required in Epic UI.  If omitted in SDK, SDK defaults current date.
 84
 85    .Comments = "Test Attachment"
 86    ''This value can be found using the lookup method(AttachmentAccessLevel)
 87    .SecurityAccessLevelCode = "Public"
 88
 89  End With
 90
 91  Dim lstAttachment As List(Of Integer) = Nothing
 92
 93  Try
 94    ' Perform the Insert
 95    lstAttachment = oClient.Insert_Attachment(p_oHeader, oAttachment)
 96
 97    ' Close the service
 98    oClient.Close()
 99
100  Catch ex As Exception
101    oClient.Abort()
102    Throw
103  End Try
104
105  ' Handle output
106  Console.WriteLine("New Attachment inserted with ID: " & lstAttachment.Item(0).ToString)
107
108Catch ex As Exception
109  Console.WriteLine("Error: " & ex.Message)
110  Console.WriteLine("Press any key to exit...")
111  Console.ReadLine()
112End Try

Example of code for get lookup supporting cultures.

VB
 1' Imports SDK2011_01 = [Project Name].schemas.appliedsystems.com.epic.sdk._2011._01
 2' Imports SDK2009_07 = [Project Name].schemas.appliedsystems.com.epic.sdk._2009._07
 3
 4' Constant DATABASE preset to current database name
 5' Constant AUTHENTICATION_KEY set to current authentication key
 6
 7Dim oService As New EpicSDK_2019_01Client ' Instantiate the Service object
 8Dim oHeader As New SDK2009_07.MessageHeader ' Instantiate the Header object
 9Dim oLookupResult As List(Of SDK2009_07._common.Lookup)  ' Instantiate the ResultObject
10
11' Populate the database and authentication key in the Header object
12oHeader.DatabaseName = DATABASE
13oHeader.AuthenticationKey = AUTHENTICATION_KEY
14oHeader.Culture = CultureCode                                   'Example fr-CA
15
16Try
17
18  'Get lookup in french
19  Dim oLookupResult As List(Of SDK2009._common.Lookup)  ' Instantiate the ResultObject
20  Dim asArgs As New List(Of String)
21  oLookupResult = oClient.Get_Lookup(p_oHeader, schemas.appliedsystems.com.epic.sdk._2009._07._common._lookup.LookupTypes.AttachmentFolder, asArgs)
22  Dim sFolder = oLookupResult.Item(4).Description.ToString  'get Lookup description(in French) for the folder to which attachment is to be added
23
24  asArgs.Add(sFolder)                 ' specify the name of the folder in the search terms to get the name of the sub folder(again the results are returned in French).
25
26
27  ' Perform the lookup call
28  oLookupResult = oService.Get_Lookup(oHeader, schemas.appliedsystems.com.epic.sdk._2009._07._common._lookup.LookupTypes.ProfitCenter, asArgs)
29
30  oService.Close()
31
32Catch ex As Exception
33  Console.WriteLine("Error: " & ex.Detail.Description)
34  Console.WriteLine("Press any key to exit...")
35  Console.ReadLine()
36  Exit Sub
37End Try
38
39For Each oLookup As SDK2009_07._common.Lookup In oLookupResult
40  Console.WriteLine("Code: " & oLookup.Code.ToString & " Description: " & oLookup.Description.ToString)
41Next