Hi Experts,
I am trying to create contract document through a script i.e reading attachment from shared location and creating new Contract Document object but the object created through script doesn't appear in Master agreement Contract Document tab. ( We don't want to use Contract Document importer option as there is no way to schedule that )
On comparing the contract document which is created via script and the one uploaded directly on system. We found out that CURR_CONFIG_PHASE_OBJECT_ID is not present in the one created through script.
Now I am trying to create an instance for Ibean ContractDocPhaseSubIBeanIfc and assign it to my contract document. But I am not able to find any methods in the interface for that.
Can you please help with the code which I can use to create instance of ContractDocPhaseSubIBeanIfc and assign it to Contract Document field CURR_CONFIG_PHASE_OBJECT_ID?
I have tried following to create instance but it throws out error. Also a point to be noted is for each Contract Document, there are four entries for each contract Document in table FCI_DOC_CONTRACT_PHASE one each for phase Draft, Supplier Draft, Waiting For Executed Approval and Executed. So will we need four instance of ContractDocPhaseSubIBeanIfc ?
ContractDocPhaseSubIBeanHomeIfc docPhaseHome = (ContractDocPhaseSubIBeanHomeIfc)IBeanHomeLocator.lookup(session, ContractDocPhaseSubIBeanHomeIfc.sHOME_NAME); ContractDocPhaseSubIBeanIfc docPhase = docPhaseHome.create();
Below is my method which creates contract Document.
void addContractAttachment(ContractIBeanIfc contract, AttachmentIfc attach) throws Exception { ContractDocumentIBeanIfc c1 = (ContractDocumentIBeanIfc)contract.getContractDocuments().create(); c1.setDisplayName(import_record.getField("DOC_DISPLAY_NAME")); queryExe = IapiQueryExecFactory.createQueryExec(session,QRY_GET_CONTRACT_DOC_TYPE_REFERENCE); params = queryExe.getParameterSet(session,QRY_GET_CONTRACT_DOC_TYPE_REFERENCE); Map filters = new HashMap(); filters.put("DocId", "Contract"); IapiQueryResultSetIfc docRecords = queryExe.execute(filters); IapiQueryResultSetMetaDataIfc docMetadata = docRecords.getMetaData(); docRecords.next(); ContractDocumentTypeIBeanHomeIfc cdHome = (ContractDocumentTypeIBeanHomeIfc)IBeanHomeLocator.lookup(session, ContractDocumentTypeIBeanHomeIfc.sHOME_NAME); ContractDocumentTypeIBeanIfc cdoc = cdHome.findByUniqueDocName(docRecords.getString(docMetadata.getFieldIndex("maDocName"))); c1.setTypeObjRef(cdoc.getObjectReference()); DocumentVersionIBeanIfc docVer = c1.getDocVersions().create(); docVer.setDoc(attach); docVer.getFieldMetadata("VERSION").set(docVer, 1); docVer.getFieldMetadata("ADDED_BY_USER").set(docVer,(session.getUserAccount().getObjRef())); docVer.setDisplayName("CLM Import Test"); c1.getDocVersions().add(docVer); c1.getFieldMetadata("SIGNED_DOC").set(c1, attach); contract.getContractDocuments().add(c1); }
Let me know if you need any more information.
Thanks
Ankit