Servicenow:表中的自定义附件窗口小部件未在Submit上载文档

问题描述 投票:0回答:1

我们的团队正在开发ServiceNow的纽约版本,并尝试将附件合并到表格小部件中。我们通过复制此post中的操作创建了一个自定义附件小部件。我们对该附件小部件的代码如下:

<now-attachments-list template="sp_attachment_single_line" ></now-attachments-list>
<label style="float:left;font-weight:normal;cursor:pointer;">
  <sp-attachment-button></sp-attachment-button>
  <!--<span style="padding-left:4px;">${please fill them in excel and attach it to this request.}<br>Click <a>here</a> to add an attachment</span>-->
</label>
<sp-message-dialog name="delete_attachment"
                   title=""
                   message=""
                   ok=""
                   cancel=""
                   dialog-class="delete-dialog"/>
function ($scope, $http, spUtil, nowAttachmentHandler, $rootScope, $sanitize, $window, $sce) {
  var c = this;
  c.quantity = 1;
  //$scope.data.sc_cat_item.description = $sce.trustAsHtml($scope.data.sc_cat_item.description);
  $scope.m = $scope.data.msgs;
  $scope.submitButtonMsg = $scope.m.submitMsg;
  var ah = $scope.attachmentHandler = new nowAttachmentHandler(setAttachments, function() {});
  ah.setParams('sp_portal', $scope.data._attachmentGUID, 1024 * 1024 * 24);
  function setAttachments(attachments, action) {
  $scope.attachments = attachments;
  }
  $scope.attachmentHandler.getAttachmentList();
  $scope.confirmDeleteAttachment = function(attachment, $event) {
      $rootScope.$broadcast("dialog.delete_attachment.show", {
          parms: {
              ok: function() {
                  $scope.attachmentHandler.deleteAttachment(attachment);
                  $rootScope.$broadcast("dialog.delete_attachment.close");
              },
              cancel: function() {
                  $rootScope.$broadcast("dialog.delete_attachment.close");
              },
              details: attachment.name
          }
      })
  }
}
(function() {
    var m = data.msgs = {};
    m.submitMsg = gs.getMessage("Submit");
    m.submittedMsg = gs.getMessage("Submitted");
    m.createdMsg = gs.getMessage("Created");
    m.trackMsg = gs.getMessage("track using 'Requests' in the header or");
    m.clickMsg = gs.getMessage("click here to view");
    m.dialogTitle = gs.getMessage("Delete Attachment");
    m.dialogMessage = gs.getMessage("Are you sure?");
    m.dialogOK = gs.getMessage("OK");
    m.dialogCancel = gs.getMessage("Cancel");

    if (input)
        data.sys_id = input.sys_id;
    else
        data.sys_id = $sp.getParameter("sys_id") || $sp.getParameter('sl_sys_id');
    data._attachmentGUID = gs.generateGUID();
    // portal can specify a catalog home page
    data.sc_catalog_page = $sp.getDisplayValue("sc_catalog_page") || "sc_home";
    var validatedItem = new GlideappCatalogItem.get(data.sys_id);
    if (!validatedItem.canView())
        return;
})()

在表格小部件中,我们将上述附件小部件嵌入到一列中:

<td>
  <widget id="custom-attachments"></widget>
</td>

最终结果看起来像这样:

enter image description here

现在,这使我们能够逐行“附加”文档,这正是我们想要的。但是,一旦我们按提交,就什么也不会发生。用户点击“提交”后,我们希望为表中的每一行创建一个新案例,并上传相应的附件并将其附加到每个新案例。在添加附件小部件之前,我们的代码创建了案例,但是现在什么也没有创建,什么也没有发生。控制台中也没有错误,因此我们不确定到底发生了什么。有什么建议吗?

angularjs file-upload attachment servicenow
1个回答
0
投票

目前看来您没有指定用于处理提交的任何服务器端代码。您是否排除了可能会过去的其他代码?

如果没有,似乎您将需要编写一个处理程序为您创建记录,而另一个处理程序将上载附件,然后将其添加到创建的记录中。


推荐问答