on a form, in a HTML cell, lets say I have a <SCRIPT>. and it calculates a value. Whats the best way to get that value into a field on the aware form?
I'd really like to ALSO Save the Form (automatically), now that the value is in that field.
The script gets called by a button on the form - its in a HTML cell and just calls the function that's inside the other HTML cell. Its a barcode scanner. Once a valid scan is returned, I want to stuff that value. They can cancel the scan, and manually type in the value also. Then they would SAVE the form. So I figured if the scan is good (its a warehouse location) I just stuff it and and start the SAVE (which starts BO Rules)
THIS IS RUNNING IN Native Aware on cell phone. Android APK
<SOLVED> Script needs to set Form Field,then auto save Form
<SOLVED> Script needs to set Form Field,then auto save Form
- Attachments
-
- SaveBarcode.PNG (7.53 KiB) Viewed 4168 times
Last edited by Jaymer on Sun Nov 17, 2019 6:14 pm, edited 1 time in total.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.
Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Aware Programming & Consulting - Tampa FL
-
- Posts: 7525
- Joined: Sun Apr 24, 2005 12:36 am
- Contact:
Re: HTML script needs to set FormField,then auto save Form.
First of all you need a "parser" object for the form. You can get it if you have any HTML element that belongs to the form:
var parser = AwareApp.getFormParserFromHtmlElem (htmlElem);
Once you have the parser you can use it to get any "attribute field" on the form:
var field = parser.getField ("AttributeName");
You can set a value into the attribute field like this:
field.setValue (value);
You can get an existing value from a field like so:
var value = field.getValue ();
Finally you can save the form like so:
parser.saveForm ();
var parser = AwareApp.getFormParserFromHtmlElem (htmlElem);
Once you have the parser you can use it to get any "attribute field" on the form:
var field = parser.getField ("AttributeName");
You can set a value into the attribute field like this:
field.setValue (value);
You can get an existing value from a field like so:
var value = field.getValue ();
Finally you can save the form like so:
parser.saveForm ();
Aware IM Support Team
SOLUTION
Thank you, this was very helpful.
Below is the contents of a HTML cell on a Form.
This is for Aware Native app to run on Android.
A user finds an Inventory item & this form is presented to capture the location from a barcode label on the shelf.
The Cordova Plugin from Build.PhoneGap activates the native camera, and the scanned value is returned upon scan success and inserted into the Aware field.
--> JaymerTip
Below is the contents of a HTML cell on a Form.
This is for Aware Native app to run on Android.
A user finds an Inventory item & this form is presented to capture the location from a barcode label on the shelf.
The Cordova Plugin from Build.PhoneGap activates the native camera, and the scanned value is returned upon scan success and inserted into the Aware field.
Code: Select all
<script>
function StartScan() {
cordova.plugins.barcodeScanner.scan(
function (result) {
if(!result.cancelled) {
var parser = AwareApp.getFormParserFromHtmlElem (btn1);
var field = parser.getField ("tmp_ShortCode");
field.setValue (result.text);
parser.saveForm ();
}
},
function (error) {alert("Scanning failed: " + error);
}, {
preferFrontCamera : true,
showFlipCameraButton : true,
showTorchButton : true,
torchOn: true,
saveHistory: false,
prompt : "Place a barcode inside the scan area",
resultDisplayDuration: 500,
formats : "CODE_39",
orientation : "portrait",
disableAnimations : true,
disableSuccessBeep: false
}
);
}
</script>
<button onclick="StartScan()">Scan Location</button>
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.
Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Aware Programming & Consulting - Tampa FL