Question:
How can you clip documents using the .NET SDK or REST API?
Answer:
Clipping documents using the API can be done in various scenarios, which will be covered in the following examples.
Using the .NET SDK
The following code examples can be used and modified depending on your situation.
Note: Be aware of the implications of clipping documents when choosing to remove a document from the source location. If the options to remove the source document is true, then it will be completely removed from the source location. Please test this functionality on a test environment first before moving to a production system.
Append a document to the back
We are passing the File Cabinet object, which contains the documents we want to clip onto the primary one, which is also the second parameter we're passing.
public static Document AppendDocuments(FileCabinet cabinet, Document doc)
{
Document DocumentAfterAppend = doc.GetDocumentFromSelfRelation().PutToProcessDocumentActionRelationForDocument(new DocumentActionInfo()
{
DocumentAction = DocumentAction.Append,
DocumentActionParameters = new AppendActionParameters()
{
// Remove documents after clipping?
RemoveSourceDocuments = true,
DocumentsAtBack = new List<AppendActionDocuments>()
{
new AppendActionDocuments()
{
Documents = new List<int>()
{
// Doc Id's from source File Cabinet
34, 35
},
SourceCabinetId = cabinet.Id
}
}
}
});
return DocumentAfterAppend;
}
Append a document in front
We are passing the File Cabinet object, which contains the documents we want to clip onto the primary one which is also the second parameter we're passing.
public static Document AppendDocuments(FileCabinet cabinet, Document doc)
{
Document DocumentAfterAppend = doc.GetDocumentFromSelfRelation().PutToProcessDocumentActionRelationForDocument(new DocumentActionInfo()
{
DocumentAction = DocumentAction.Append,
DocumentActionParameters = new AppendActionParameters()
{
// Remove documents after clipping?
RemoveSourceDocuments = true,
DocumentsInFront = new List<AppendActionDocuments>()
{
new AppendActionDocuments()
{
Documents = new List<int>()
{
// Doc Id's from source File Cabinet
34, 35
},
SourceCabinetId = cabinet.Id
}
}
}
});
return DocumentAfterAppend;
}
Clipping from Document Tray to File Cabinet
To clip a document from the document tray to one in the file cabinet, you would pass the document tray's guid to the function.
Clipping from File Cabinet to File Cabinet
To clip a document from the file cabinet to one that's in another file cabinet, you would pass the file cabinet's guid to the function.
Clipping from within the same File Cabinet
To clip a document that's in the same file cabinet, you'd pass the file cabinet guid to the function.
Using the REST API
The following endpoint will be used and can be modified to account for the following situations.
Endpoint: {{ServerUrl}}/{{Platform}}/FileCabinets/{{File Cabinet Guid}}/Operations/ProcessDocumentAction?docId={{DocId}}
Note: Clipping documents from a file cabinet to a document in a document tray, or clipping documents from the same document tray is not a supported method. If tried, you will receive the following error,
"Operation not supported for document trays! Specified method is not supported."
For clipping documents in front
Body request:
For clipping documents in the back
Body request:
Clipping from Document Tray to File Cabinet
To clip a document from a document tray to one that's in a file cabinet, you'll reference the file cabinet's guid in the endpoint's URL, and then you'll reference the document tray's guid in the body request for "SourceCabinetId".
Clipping from File Cabinet to File Cabinet
To clip a document from a file cabinet to one that's in another file cabinet, you'll reference the destination file cabinet's guid in the endpoint's URL, and then you'll reference the source file cabinet's guid in the body request for "SourceCabinetId".
Clipping from within the same File Cabinet
To clip documents from within the same file cabinet, you'll reference the file cabinet's guid in both the endpoint's URL and in the body request for "SourceCabinetId".
KBA applicable for both Cloud and On-premise Organizations