ServiceNow:访问 mdDialog 中的小部件选项架构

标签 servicenow angularjs-material mddialog

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

enter image description here

我有一个单独的小部件,它嵌入了我克隆的 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'
})

它们都不起作用,而且我似乎找不到任何有关如何执行此操作的文档。有什么建议么?谢谢!

最佳答案

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

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

When a widget is called using spUtil (client) then the parameters passed are accessed using "input".

When a widget is called using $sp (server) then the parameters passed are accessed using "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

关于ServiceNow:访问 mdDialog 中的小部件选项架构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49019274/

相关文章:

java - 如何根据来电者过滤service now事件记录?

服务现在 : Jelly Error

AngularJS多复选框疑惑(Angular Material)

html - Angular Material layout-align center 不影响小模式下的文本

html - 如何设置$mdDialog 的最大宽度?

python - 如何将事件参数传递给运行以响应 Splunk 警报的 Python 脚本?

javascript - 通过javascript设计的中间服务器探针调用java jar方法

angularjs - 我如何更改 Angular Material md-primary 按钮文本颜色?

javascript - 如何删除 Angular js 确认对话框弹出窗口中的按钮?