cancel
Showing results for 
Search instead for 
Did you mean: 

SAP MDK OnValueChange event issue

madhavi_beedam87
Explorer
0 Kudos

Hi Experts,

I am using a Android based TC72 device which has a inbuilt scanner.

My requirement is, in a page have a SimpleProperty with OnValueChange calling a rule. 

When a user  scans a barcode, I have to show an alert and clear the Input Field for next scan.

Issue : Its working for the first time as expected but second time its still retaining the first scan value. (I am scanning two different barcodes alternatively for testing) So my OnValueChange triggering twice. (one with OLD value and again with NEW value).

My Rule Code inside the default function as below

var scannedValue = clientAPI.getValue();
alert("Scanned Value first time :" + scannedValue + ":");
clientAPI.setValue("", false); // Doing this to stop second call to the event
alert("Scanned Value second time :" + clientAPI.getValue() + ":"); // this is still showing the value
 
 

 

 

 

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos
What version of MDK are you using?

Accepted Solutions (0)

Answers (3)

Answers (3)

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

I am assuming you are using the data wedge configuration for the scanning where the scan value is input into the current cursor location and have a simple property field where the OnValueChange rule is attached.

When you open the page and tap into the field and then scan your first value the OnValueChange rule will be called and clientAPI.getValue() will contain the scanned value.  Subsequent scans will trigger the OnValueChange rule again with the new scanned value.

Within your OnValueChange rule you are calling setValue to clear the current scan value.  The setValue returns a promise so simply calling clientAPI.getValue() again will still return the current scan value but the promise will complete and the next scan will correctly contain the next scan value.  

I tested this using my TC77 and see the expected results where each time I scan I get the current scan value.

 

madhavi_beedam87
Explorer
0 Kudos
Hi Experts, Any updates on this issue ? -Madhavi
bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos
What version of MDK are you using?
madhavi_beedam87
Explorer
0 Kudos

Hi Bill,

MDKClient Version : 23.12.0-002

com.sap.cloud.android.fundation : 7.1.0

 

-Madhavi Beedam