Any idea or suggestion on this please:
Process > on Browse Screen > on Search Field, scan Barcode or RFID > triggers search, and when record found, automatically open record in Edit Form in Modal Mode
Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
Barcode or RFID Search
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: Barcode or RFID Search
You'll need a barcode library like Quagga:
https://github.com/serratus/quaggaJS
Then specify nuSearchField as target
In the onProcessed event you can open the record. I'm not quite sure how to open a record by specifying a filter string though.
https://github.com/serratus/quaggaJS
Then specify nuSearchField as target
Code: Select all
target: document.querySelector('#nuSearchField')
-
- Posts: 79
- Joined: Thu Oct 20, 2011 9:13 pm
Re: Barcode or RFID Search
You can configure the barcode reader to send an 'Enter' keystroke when it reads the barcode.
The browse form must contain a column with all the barcodes.
When a browse form is opened the cursor is located on the serach field. Therefore when the barcode reader scans a barcode, the text of the barcode is entered on the search field, and when the 'Enter' keystroke is sent by the barcoode reader, the browse form will find the record corresponding to the scanned barcode.
I am not sure how to program the JS to open the record when it is found, but I noticed the following:
The 'words' that match with the searh field in the browse form rows have this code:
So, you might want consider creating a JavaScript function that is executed when the browse form is opened.
This function needs to search for 'span' elements containing the 'nuBrowseSearch' class. If only one element is found then simulate a click on it and the edit form will be opened.
If two or more elements are found, it means that there are more than one record with the corresponding barcode, and the edit form should not be opened in order for the user to notice that.
Fike
The browse form must contain a column with all the barcodes.
When a browse form is opened the cursor is located on the serach field. Therefore when the barcode reader scans a barcode, the text of the barcode is entered on the search field, and when the 'Enter' keystroke is sent by the barcoode reader, the browse form will find the record corresponding to the scanned barcode.
I am not sure how to program the JS to open the record when it is found, but I noticed the following:
The 'words' that match with the searh field in the browse form rows have this code:
Code: Select all
<span class="nuBrowseSearch" onclick="this.offsetParent.onclick()">WORD THAT MATCHES THE SEARCH FIELD</span>
This function needs to search for 'span' elements containing the 'nuBrowseSearch' class. If only one element is found then simulate a click on it and the edit form will be opened.
If two or more elements are found, it means that there are more than one record with the corresponding barcode, and the edit form should not be opened in order for the user to notice that.
Fike
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: Barcode or RFID Search
Fike,Fike wrote: I am not sure how to program the JS to open the record when it is found, but I noticed the following:
This could be done like this:
Code: Select all
if (nuFormType() == 'browse') {
custSelectBrowseFirst();
}
function custSelectBrowseFirst() {
// open the record (in the edit form) if just 1 record is found:
var p1 = $('#nucell_0_0').attr('data-nu-primary-key'); // primary key of 1st row
var p2 = $('#nucell_1_0').attr('data-nu-primary-key'); // primary key of 2nd row
if (p1 !== undefined && p2 === undefined) { // if just one record is returned
$("div[id='nucell_0_0']").click();
}
}
The .click(); could also replaced with this code:
Code: Select all
var f = window.nuFORM.getProperty('form_id');
var r = window.nuFORM.getProperty('redirect_form_id');
if(r == ''){
nuForm(f, p1);
}else{
nuForm(r, p1);
}