階層選択フィールの作成
2795 ワード
概要
参照フィールドの選択に基づいて他選択フィールドの内容を変える
今回の例では「会社」参照フィールドで選択された子会社をリストコレクタかから選択可能にする
実装
変数vrm_vendor_lookupのonChangeスクリプト
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var vendorGA = new GlideAjax('GetVendorLocations');
vendorGA.addParam('sysparm_name', 'get_locations');
vendorGA.addParam('sysparm_vendor_id', newValue);
vendorGA.getXMLAnswer(function(answer) {
var subsidiary = JSON.parse(answer);
g_form.setValue('vrm_new_satellite_existing_location', subsidiary);
});
}
スクリプトインクルード
var GetVendorLocations = Class.create();
GetVendorLocations.prototype = Object.extendsObject(AbstractAjaxProcessor, {
get_locations: function() {
var locations = [];
var vendorID = this.getParameter('sysparm_vendor_id');
var satelliteOffice = new GlideRecord('core_company');
satelliteOffice.addQuery('parent.sys_id', vendorID);
//satelliteOffice.addQuery('vendor', true);
satelliteOffice.query();
gs.log('Denis has this ID ' + vendorID);
while (satelliteOffice.next()) {
locations.push(satelliteOffice.sys_id.toString());
}
return JSON.stringify(locations);
},
type: 'GetVendorLocations '
});
上のコードを実装すると次のように子会社がリストコレクタに選択される。
しかし、ユーザはまだ登録されている会社すべてを選択することが可能。
Author And Source
この問題について(階層選択フィールの作成), 我々は、より多くの情報をここで見つけました https://qiita.com/htshozawa/items/887997acf9b208183734著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .