通过API添加的VWAttachment未在CM 5.2中显示

时间:2014-05-19 23:27:48

标签: filenet-p8 filenet filenet-process-engine ibm-case-manager

我使用API​​检索了一个工作项,并使用setParameterValue更改了附件字段,使用stepElement.doSave(true)保存工作后,我可以通过流程管理控制台查看流程跟踪器中添加的附件,但是我的问题是它没有出现在导航器和在desktopXT中也显示"Attachment may be corrupted or deleted"

下面是我用来创建附件的代码

        tempAtt.setAttachmentName("check.png");
        tempAtt.setAttachmentDescription("Added by code");
        tempAtt.setType(VWAttachmentType.ATTACHMENT_TYPE_DOCUMENT);
        tempAtt.setLibraryType(VWLibraryType.LIBRARY_TYPE_CONTENT_ENGINE);
        tempAtt.setLibraryName("TOS");
        tempAtt.setId(doc.getVersionSeries().getId());
 tempAttA[0] = tempAtt;
 stepElement.setParameterValue("Zip", tempAttA, true);

我不明白我错在哪里,请建议。

// Filenet p8 5.2,Content Platform Engine

1 个答案:

答案 0 :(得分:0)

在敲了几个小时后得到了解决方案,发布了整个代码,可能对其他人有帮助

     //Connect to PE   
        //Query the queue with wobnum and get the workobject
                    queryIndex = "F_WobNum";
                    queryMin[0] = wob;
                    queryMax[0] = wob;
                    queryFlag = VWQueue.QUERY_MIN_VALUES_INCLUSIVE +   VWQueue.QUERY_MAX_VALUES_INCLUSIVE;
                    queryType = VWFetchType.FETCH_TYPE_WORKOBJECT;
                    queryTypeStepElement = VWFetchType.FETCH_TYPE_STEP_ELEMENT;
                    queue = session.getQueue("Queue_Name");
                    query = queue.createQuery(queryIndex, queryMin, queryMax, queryFlag, null, null, queryType);
                    System.out.println("count " + query.fetchCount());
                    workObject = (VWWorkObject) query.next();
    //get the stepelement 
                    stepElement = workObject.fetchStepElement();
                    parameters = stepElement.getParameters(VWFieldType.ALL_FIELD_TYPES, VWStepElement.FIELD_USER_AND_SYSTEM_DEFINED);

   //get the existing attachment value
         tempAttA= (VWAttachment[]) stepElement.getParameterValue("attachment_field_name");
//attachment is VWAttachment array          
attachment=tempAttA;
//lock the item for working
            stepElement.doLock(true);
//set the new values for the new attachment to be added          
            tempAtt=new VWAttachment();
            tempAtt.setAttachmentName("Attachment_name");
            tempAtt.setAttachmentDescription("Added by code");
            tempAtt.setType(VWAttachmentType.ATTACHMENT_TYPE_DOCUMENT);
            tempAtt.setLibraryType(VWLibraryType.LIBRARY_TYPE_CONTENT_ENGINE);
            tempAtt.setLibraryName("TOS");
//vs id of the existing CE document , note that  adding attachment means refering a CE object , so the document u want to attach should be stored in CE before.
            tempAtt.setId(doc.getVersionSeries().getId());
            attachment=tempAttA;
//law is a arraylist of VWAttachment type , so u dont override any existing attachments
            law.add(attachment[0]);
            law.add(tempAtt);
//set the attchment field with new values
            stepElement.setParameterValue("attachment_name", law.toArray(), true);