If you have questions or if you want to share your opinion about Aware IM post your message on this forum
#52100 by Jaymer
Fri Nov 15, 2019 10:11 pm
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
SaveBarcode.PNG (7.53 KiB) Viewed 534 times
Last edited by Jaymer on Sun Nov 17, 2019 6:14 pm, edited 1 time in total.
#52102 by aware_support
Sun Nov 17, 2019 12:16 am
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 ();
#52106 by Jaymer
Sun Nov 17, 2019 6:13 pm
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.

Code: Select all<script>
function StartScan() { 
    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

<button onclick="StartScan()">Scan Location</button>

--> JaymerTip

Who is online

Users browsing this forum: No registered users and 23 guests