メインコンテンツへスキップ
このサンプル スクリプトは、Web Verification Station でデータベース内のデータを検索します。 このユーザー スクリプトの設定に進む前に、必ず次の手順を完了してください。
  1. Project Setup Station を開き、Project → Document Definitions… をクリックします。
  2. Document Definition → Document Definition Properties, をクリックし、Data Sets タブを開いてから、Add… をクリックします。
  3. データ セットを作成し**、**いくつかのレコードを作成して、Close をクリックします。
新しいユーザー スクリプトが Web Verification Station 用のスクリプト エディター に追加されます。
//データセット名
var dbCacheName = 'DataSet1';
//データセット内のfield。現在のfieldの値を置き換えるために使用する
var fieldNameInCache = 'Field2';
var self = this;
var styles = {
display: 'block',
position: 'absolute',
top: '0px',
bottom: '0px',
left: '0px',
right: '0px',
width: '100%',
height: '100%',
border: '0',
overflow: 'hidden',
'overflow-x': 'hidden',
'overflow-y': 'hidden',
'z-index': '10000'
}
var newValueToInsert = '';
// iframeのスタイルを設定する
setStyles(
styles,
function() {
//ダイアログのマークアップ
var windowMarkup = "<div class='frame'><div class='searchField'><input id='searchValue' /><button id='searchButton'>Search</button></div><div id='recordspanel'><table id='resultspreview'></table><div id='norecord'>No records found</div></div><div class='buttonsfield'><button id='confirm'>Ok</button><button id='cancel'>Cancel</button></div></div>";
//ダイアログスタイル
var css = "<style>body{width:100vw;height:100vh;background:rgba(0,0,0,0.1);margin:0;padding:0;display:flex;align-items:center;justify-content:center;}.frame{width:400px;max-height:80vh;background:white;min-height:200px;padding:50px;}#norecord{display:none;}#searchValue{width:calc(100% - 60px);}#cancel{margin-left:20px;}.buttonsfield{display:flex;justify-content:flex-end;height:25px;}.bolded{font-weight:bold;}button{width:60px;}#confirm{display:none;}#recordspanel{min-height:145px;padding: 10px 0;}#searchfield{height:30px;}</style>";
//スタイルを設定する
$('head').append(css);
//iframeにDOMを作成する
$("body").append(windowMarkup);
// 検索ボタンのクリック
$('#searchButton').click(function () {
//辞書を検索
getDict(
{
cacheName: dbCacheName, //データセット名
filters: [{ FieldName: "", FieldValue: $('#searchValue').val() }] //検索するfields
},
function (result) {
//データセットから行を取得
var records = result.detail.result;
//最初の行の説明
var firstRecord = records[0];
//結果が見つからない場合は「テーブル」と「OK」ボタンを非表示にする
if (!firstRecord && !firstRecord.BoldMask){
$('#resultspreview').hide();
$('#norecord').show();
$('#confirm').hide();
} else {
$('#resultspreview').show();
$('#confirm').show();
$('#norecord').hide();
$('#resultspreview').html('');
firstRecord.forEach(function (recordData) {
if (fieldNameInCache === recordData.FieldName) {
newValueToInsert = recordData.FieldValue;
}
$('#resultspreview')
.append('<tr class="' +
(fieldNameInCache === recordData.FieldName ? 'bolded' : '') +
'"><td>' +
recordData.FieldName +
'</td><td>' +
recordData.FieldValue +
'</td></tr>');
});
}
});
});
//'ok' ボタンクリック時
$('#confirm').click(function () {
if (newValueToInsert) {
//現在のfieldに値を設定する
setCurrentFieldValue(newValueToInsert);
//iframeを保存して閉じる
save();
}
});
//'cancel' ボタンクリック時
$('#cancel').click(function () {
cancel();
});
});
このサンプル スクリプトは、https://<ApplicationServer>/FlexiCapture12/Verification/Scripts/CustomScripts/customActionLookup.js, にもあります。ここで、<ApplicationServer> は Application Server がインストールされているコンピューター名です。 サンプル スクリプト内の以下の行の値を置き換えます。
  • var dbCacheName = ‘DataSet1’, ここで DataSet1 は先ほど作成したデータ セットの名前です。
  • var fieldNameInCache = ‘Field2’, ここで Field2 は、コピーする値を含むデータ セットの field 名です。