cancel
Showing results for 
Search instead for 
Did you mean: 

Exporting Contract Document Attachments

Former Member
0 Kudos

Hi All,

I am trying to extract all contract documents in CLM application to a folder. Can anyone please share the steps to accomplish this?

Thanks,

Saloni

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member207877
Active Participant
0 Kudos

Hi Saloni,

Please go through below link. It might be helpful.

Regards,

Raj

Former Member
0 Kudos

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


kushagra_agrawal
Active Participant
0 Kudos

Hi Saloni,

As per my understanding of your requirement, follow the below steps:

1. Write a query which will fetch all the MAs depending upon the condition

2. Create a explicit script.

3. You have to call the query which will get all the MAs depending on the condition in the script. Write the logic in the script that what you want to achieve.

4. Create a Schedule job and call the explicit script.

5. Run the Job.

Below the blog which will guide you how to use Query IAPIs

Hope it helps.

Thanks

Kushagra A

Former Member
0 Kudos

Hi Kushagra,

I am working on CLM 5.0, and its not having calling Explicit script feature.

Can you please check whether the code given in my last post fine?

Thanks,

Saloni