Skip to main content
This sample script will search for data in a database at the Web Verification Station. Before you proceed to configure this user script, be sure to complete the following steps:
  1. Open the Project Setup Station and click Project → Document Definitions…
  2. Click Document Definition → Document Definition Properties, open the data sets tab, and then click Add….
  3. Create a data set**,** create a few records, and click Close.
A new user script will be added to the Script Editor for Web Verification Station.
//DataSet Name
var dbCacheName = 'DataSet1';
//Field in dataset, used to replace current field value
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 = '';
// Sets iframe styles
setStyles(
styles,
function() {
//Dialog markup
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>";
//Dialog styles
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>";
//Set styles
$('head').append(css);
//Creates dom in iframe
$("body").append(windowMarkup);
// Search button click
$('#searchButton').click(function () {
//Look in Dictionary
getDict(
{
cacheName: dbCacheName, //dataset name
filters: [{ FieldName: "", FieldValue: $('#searchValue').val() }] //fields to search
},
function (result) {
//Records  rows from dataset
var records = result.detail.result;
//First row description
var firstRecord = records[0];
//hide 'table' and 'ok' button if no result is found
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>');
});
}
});
});
//On 'ok' button click
$('#confirm').click(function () {
if (newValueToInsert) {
//Set value to current field
setCurrentFieldValue(newValueToInsert);
//Save and close iframe
save();
}
});
//On 'cancel' button click
$('#cancel').click(function () {
cancel();
});
});
This sample script can also be found here: https://<ApplicationServer>/FlexiCapture12/Verification/Scripts/CustomScripts/customActionLookup.js, where <ApplicationServer> is the name of the computer where the Application Server is installed. Replace the values in the following lines of the sample script:
  • var dbCacheName = ‘DataSet1’, where DataSet1 is the name of the data set created earlier.
  • var fieldNameInCache = ‘Field2’, where Field2 is the name of the data set field that will contain the value to be copied.