【问题标题】:ServiceNow: accessing widget option schema in mdDialogServiceNow:在 mdDialog 中访问小部件选项架构
【发布时间】:2018-08-07 17:25:05
【问题描述】:

我已经克隆了 OOTB 小部件表单,将其命名为 widget-form-md,并为 hideRelatedLists 创建了一个附加选项架构:

我有一个单独的小部件,它嵌入了我克隆的 widget-form-md,并希望通过 Material Design 模态显示它。我的模态客户端脚本如下所示:

function x ($scope, $location, spUtil, amb, $mdDialog, $http, $window, $rootScope, $timeout){
var c = this;

c.newRequest = function() {
$mdDialog.show({
contentElement: '#hr_request',
parent: angular.element(document.body),
clickOutsideToClose:true
});
spUtil.get("widget-form-md", {
request_name: 'hr_request',
view: 'hr_request',
table: 'x_dnf_federal_hr_e_federal_hr_cases'
}).then(function(response) {
c.hr_request = response;
});
};
}

将我的选项架构传递到 spUtil 的正确语法是什么?我试过了

spUtil.get("widget-form-md", {
request_name: 'hr_request',
hideRelatedLists: true
view: 'hr_request',
table: 'x_dnf_federal_hr_e_federal_hr_cases'
})

spUtil.get("widget-form-md", {
request_name: 'hr_request',
options: {hideRelatedLists:true},
view: 'hr_request',
table: 'x_dnf_federal_hr_e_federal_hr_cases'
})

他们都没有工作,我似乎找不到任何关于如何做到这一点的文档。有什么建议?谢谢!

【问题讨论】:

    标签: servicenow angularjs-material mddialog


    【解决方案1】:

    首先:Option Schema 用于通过表格配置小部件: https://dxsherpa.com/blogs/widget-options-schema-in-service-portal/

    在被调用小部件的选项中未显示的缺少参数的解决方案在这里:https://community.servicenow.com/community?id=community_question&sys_id=ea83c365dbd8dbc01dcaf3231f9619d2

    当使用 spUtil(客户端)调用小部件时,使用“input”访问传递的参数。

    当使用 $sp(服务器)调用小部件时,使用 "options"

    访问传递的参数

    由于使用 spUtil 调用小部件,我们在输入对象中拥有服务器上的数据。因此在被调用小部件的服务器中:

    data.requestName = input.request_name;
    data.hideRelatedLists = input.hideRelatedLists;
    // or the short version, if widget also gets parameters from URL and options:
    data.requestName = $sp.getParameter('requestName ') || options.requestName || input.requestName;
    
    

    很遗憾,官方文档中没有对此进行描述:https://developer.servicenow.com/app.do#!/api_doc?v=london&id=spUtilAPI

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-03
      • 1970-01-01
      • 1970-01-01
      • 2017-06-13
      • 1970-01-01
      • 2017-06-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多