Navigation:


FORUMS > SentryFile Version 5 Topics > SF5 - API Integration / Programming Assistance < refresh >
Topic Title: API Integration Adding Documents
Created On Thu May 03, 2012 3:51 PM
Topic View:

View thread in raw text format


jdstallings

Posts: 10
Joined: Apr 2012

Thu May 03, 2012 3:51 PM
User is offline View users profile

I am currently developing a connector to Sentry File from our BPM system using your webservices. I have been successful adding documents through the SF web services.
However I'm not sure the steps I should follow when adding a document that has multiple files.
Should I perform an Add_PutFile for each separate file or just perform one Add_Putfile followed by Attachments_Add for each of the remaining files?

Thanks
James
 
Reply
   
Quote
   
Top
   
Bottom
     



SupportRep

Posts: 6587
Joined: Feb 2004

Thu May 03, 2012 3:58 PM
User is offline

Depends on what you are trying to achieve...

Are the additional files new "revisions" of the initial file? If so, use Add_PutFile.

If you want the additional files attached to the initial file, then use Attachments_Add.

If the additional files are completely separate records, then you should call Add_CreateRecord which will give you a document_ID, then call Add_PutFile to upload the associated file to the new record.

Hope this helps!

-------------------------
-SentryFile Support
 
Reply
   
Quote
   
Top
   
Bottom
     



jdstallings

Posts: 10
Joined: Apr 2012

Fri May 04, 2012 1:20 PM
User is offline View users profile

I have added some code to add attachments to an example you guys had on the API Integration support. Would this be the correct procedure to add the attachments once the document is active and searchable? See below in the 'Add Attachments section

Thanks


'Create a new docucore object
Dim dc As New DocuCore.DocuCore

'log into a SF session
Dim sessionid As String = dc.Session_Signin("admin", "admin")

'make sure a session id is returned. Empty session id means the login failed.
If sessionid <> "" Then
'Find the appropriate cabinet ID
dim cabinetid as integer = dc.Repository_RetrieveID(sessionid, "Human Resources")

'Create a new record in the appropriate cabinet
Dim docid As Integer = dc.Add_CreateRecord(sessionid, cabinetid)

'Put the file into the record
dc.Add_PutFile(sessionid, cabinetid, docid, "test.pdf", "", ReadFile("c:\test.pdf"))

'add the index data

'Employee Name - Text Field
dim fieldid as Integer = dc.RepositoryField_RetrieveID(sessionid, "Employee Name", cabinetid)
if dc.add_Validate_Text(sessionid, fieldid, "Homer Simpson") then
if dc.Add_PutIndex_Text(sessionid, cabinetid, docid, fieldid, "Homer Simpson") then
'Successfully saved index data for this field.
else
'failed to save index data for this field. Insert appropriate error handler here
end if
else
'Failed to validate the index data for this field. Insert appropriate error handler here
end if


'Date - Date field
fieldid = dc.RepositoryField_RetrieveID(sessionid, "Date", cabinetid)
if dc.add_Validate_Date(sessionid, fieldid, DateTime.now()) then
if dc.Add_PutIndex_Date(sessionid, cabinetid, docid, fieldid, DateTime.now()) then
'Successfully saved index data for this field.
else
'failed to save index data for this field. Insert appropriate error handler here
end if
else
'Failed to validate the index data for this field. Insert appropriate error handler here
end if

'Verify that the record is active... If the record meets all criteria, calling this method makes it available for searching.
If dc.Add_RecordIsActive(sessionid, cabinetid, docid) Then
'Record is active and available for searching
End if

'Add Attachments*********************************************************************************

Dim revisionid as Integer = dc.Revision_RetrieveCurrentRevisionID(sessionid,cabinetid,docid)

Dim addattach as Integer = dc.Attachments_Add(sessionid,cabinetid,docid,revisionid,"attachment.pdf",ReadFile("c:\attachment.pdf"))


'Add Attachments**********************************************************************************

else
'Login Failed. Display Error.
msgbox "Error - could not sign in"
end if



'-----------------
Public Function ReadFile(ByVal FilePath As String) As Byte()
Dim fs As FileStream
Try
' Read file and return contents
fs = File.Open(FilePath, FileMode.Open, FileAccess.Read)
Dim lngLen As Long = fs.Length
Dim abytBuffer(CInt(lngLen - 1)) As Byte
fs.Read(abytBuffer, 0, CInt(lngLen))
Return abytBuffer
Catch exp As Exception
msgbox "Expception - could not open file."
Finally
If Not fs Is Nothing Then
fs.Close()
End If
End Try
End Function

 
Reply
   
Quote
   
Top
   
Bottom
     



SupportRep

Posts: 6587
Joined: Feb 2004

Fri May 04, 2012 3:13 PM
User is offline

Yep, the code looks good. Did you get any errors or have any problems with it?

Quick question... are you certain that you want to add the documents as attachments? That's not a very common task. Most of the time, API integrations are about adding new records to cabinets by using Add_CreateRecord , then Add_PutFile. Can you tell us about the business problem you are trying to solve with your API integration? Maybe we can steer you in the right direction!


-------------------------
-SentryFile Support
 
Reply
   
Quote
   
Top
   
Bottom
     



jdstallings

Posts: 10
Joined: Apr 2012

Mon May 07, 2012 8:34 AM
User is offline View users profile

I do believe the documents would need to be attachments in the SentryFile method of classification. We have BPM system based on electronic forms which typically has one or more attachments attached to the form as they are routed in the workflow system. Once the eforms have completed their workflow processes we need to save them in the Sentry File repository with the attachments. We collect the indexes from fields on the eform and need to save the form and the attachments. It just seemed to me the attachment route was the best. I am certainly open to suggestions if you feel their is a better alternative.

I have tested all of the code except for the two methods for adding attachments. I could not find any documentation per say on adding attachments and I was making an educated guess on the process for adding attachments to an existing document.

Thanks
James
 
Reply
   
Quote
   
Top
   
Bottom
     



SupportRep

Posts: 6587
Joined: Feb 2004

Mon May 07, 2012 11:02 AM
User is offline

Okay, sounds good!

If you run into any trouble, please let us know!

Cheers

-------------------------
-SentryFile Support
 
Reply
   
Quote
   
Top
   
Bottom
     

View thread in raw text format
FORUMS > SentryFile Version 5 Topics > SF5 - API Integration / Programming Assistance < refresh >

Navigation:

FuseTalk 4.0 © 1999-2003 FuseTalk Inc.