Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9076

Re: Exporting Contract Document Attachments

$
0
0

Hi Raj,

 

I have gone through this post. I require to download all the attachments in the CLM application, and according to the post I would require to run the script on each contract to get it downloaded. I want some solution through which I can download the entire contract documents.

 

I tried writing a toolbar script as below, but its not working.

 

//Script

parentBean=doc.getParentIBean();
parentObjRef=doc.getExtensionField("PARENT").get();
parentClassId = parentObjRef.getClassId();

IapiDbHandleIfc dbHandle = session.getDbHandle();

try
{
if(parentClassId == 1003){
st = "SELECT T3.UNIQUE_DOC_NAME, T3.FILE_DATA FROM FCI_AGREEMENT T1 JOIN FCI_ATTACHMENT_SUB T2 ON (T2.PARENT_OBJECT_ID = T1.ObjectId) JOIN FCI_ATTACHMENT_BLOB T3 on (T3.PARENT_OBJECT_ID = T2.ObjectId)";
}
else if(parentClassId == 1004){
st = "SELECT T3.UNIQUE_DOC_NAME, T3.FILE_DATA FROM FCI_CONTRACT T1 JOIN FCI_ATTACHMENT_SUB T2 ON (T2.PARENT_OBJECT_ID = T1.ObjectId) JOIN FCI_ATTACHMENT_BLOB T3 on (T3.PARENT_OBJECT_ID = T2.ObjectId)";
}

java.sql.PreparedStatement ps = dbHandle.prepareStatement(st);
dbHandle.beginTransaction();
dbHandle.executeQuery(ps);

for(; dbHandle.next(); Logger.info(logMsg))
{
//InputStream FileData = dbHandle.getBinaryStream (2);
FileOutputStream file = null;
fileName = dbHandle.getString(1);
byte[] bytes = dbHandle.getBytes(2);
try
{
file = new FileOutputStream (fileName);
file.write(bytes);
}
catch (Exception e)
{
String err = e.toString();
System.out.println("File ERROR *** "+err);
}
finally
{
if(file != null)
file.close();
}
logMsg.setLogMessage(" File Name " + fileName);
}
dbHandle.endTransaction();
if (ps != null)
{ ps.close(); }
}
catch(Exception e)
{
logMsg.setException(e);
Logger.error(logMsg);
}
//End of Script

 

Please provide inputs.

 

Thanks,

Saloni



Viewing all articles
Browse latest Browse all 9076

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>