Table of Contents

Search

  1. Preface
  2. Overview, Downloading, and Installing
  3. Administration API
  4. Identity Service API
  5. Screenflow Programming and SDK
  6. ActiveVOS WSHT API
  7. Embedding Request Forms in Standalone Web Pages
  8. XML-JSON for Process Central

APIs, SDKs, and Services

APIs, SDKs, and Services

Task Attachment URL

Task Attachment URL

Task Attachment URL
In some cases, you may want to display attachment information on a Web page. In order to do this, you need to access the list of attachment meta data (attachment infos) from the WSHT
getAttachmentInfos
operation or via the
attachmentInfo
elements that are part of
taskInstance
(obtained from the
getInstance
extension operation).
The URL to the attachment content can be built using the
AE_TASK_UTIL.getAttachmentUrl(taskId, attachmentName, attachmentId)
function.
// // 1) Using getAttachmentInfos wsht API call. // var taskId = "urn:b4p:1235"; // task id var getAttachmentInfosReq = { "getAttachmentInfos" : { "xmlns" : "http://www.example.org/WS-HT/api/xsd", "identifier" : { "$t" : taskId } } }; AE_AJAX_SERVICE_UTIL.postJSON( // task-client service url "http://localhost:8080/active-bpel/services/JSON/AeB4PTaskClient-taskOperations", // req. getAttachmentInfosReq, // success callback of JSON data function(aJsonResponse) { // handle getAttachmentInfosResponse var attachmentInfoList = AE_JSON_NODE_UTIL.getElements(aJsonResponse.getAttachmentInfosResponse.info); var i; for (i = 0; i < attachmentInfoList; i++) { var info = attachmentInfoList[i]; var attachmentId = AE_JSON_NODE_UTIL.getText(info.attachmentId); var attachmentName = AE_JSON_NODE_UTIL.getText(info.name); // file name var contentType = AE_JSON_NODE_UTIL.getText(info.contentType); // mime type. var attachUrl = AE_TASK_UTIL.getAttachmentUrl(taskId, attachmentName, attachmentId); // do something with this info such as displaying on page. // (the attachUrl can be used for href attribute in <a> tags and src in <img> tags) } }, // fault callback of JSON data function(aJsonFault) { alert("Fault!"); }, // http error callback function(aStatusCode, aStatusMessage) { alert("Transport error: " + aStatusCode + " " + aStatusMessage); } ); // // 2) Alternate method of getting attachment info via AeTask object. // var taskApi = new AeTaskApi(); taskApi.getInstance( "urn:b4p:1235", // task ID function(aTask) { // handle success response var attachmentInfoList = aTask.getAttachments(); var i; for (i = 0; i < attachmentInfoList; i++) { var info = attachmentInfoList[i].attachmentInfo; var attachmentId = AE_JSON_NODE_UTIL.getText(info.attachmentId); var attachmentName = AE_JSON_NODE_UTIL.getText(info.name); // file name var contentType = AE_JSON_NODE_UTIL.getText(info.contentType); // mime type. var attachUrl = AE_TASK_UTIL.getAttachmentUrl(aTask.getId(), attachmentName, attachmentId); // do something with this info such as displaying on page. // (the attachUrl can be used for href attribute in <a> tags and src in <img> tags } }, function(aJsonFault) { alert( "Fault!"); }, function(aStatusCode, aStatusMessage) { alert( "Transport error: " + aStatusCode + " " + aStatusMessage); } );

0 COMMENTS

We’d like to hear from you!