Hello Everyone,
I need some assistance with code creation whereby after I scan my barcode it will auto-populate another question on the form pertaining to "address". The calculated expressions are being applied in ArcGIS Field Maps within the Form. Please see code attached at the bottom of this posting.
I was first able to obtain some helpful code examples via github but I am definitely missing something. The examples on github center around extracting certain components from the barcode and converting them to descriptions versus the numeric code. For my situation, the entire barcode is equivalent to the address whereby each barcode is uniquely assigned to this address information.
My workflow for this is as such...I scan the barcode, it populates the "OldMeterNumber" field with 1NF314421199 and in turn populates my "Address" field with 69944 SUNNYFIELD RD.
At this point, it keeps coming up "Unknown".
Thank you for taking the time and assisting.
Jeff
var BARCODE = $feature.OldMeterNumber
var address = BARCODE
var d = Dictionary(
"1NF314421199", "69944 SUNNYFIELD RD")
if (hasKey(d, address)) {
return d[address]
} else {
return "Unknown"
}
Solved! Go to Solution.
You can just add in the return to shortcut the other part of the code. You don't need to remove the rest, since it will never hit it. This is just to test whether the value getting stored in the OldMeterNumber field is what you're expecting.
Hi Ken,
Can you please provide a screenshot of where you would like me to put the code in conjunction to the rest of the lines? I just want to make sure I am doing it correctly.
Thanks.
Jeff
var lookupValue = $feature.OldMeterNumber;
return lookupValue;
var d = Dictionary(
"1NF314421199", "69944 SUNNYFIELD RD")
//rest of code
What I'm suggesting is to run this in your application, not testing it. As we said before, clicking the Test button just shows the result of the first record in your data set, not the record that was scanned in. Have you examined your data set to see what that first record looks like?
Okay. I ran it using the ArcGIS Field Maps app and it scanned the barcode and populated the address field with the barcode number instead of the address.
OK, next remove line 2 from my post above so it completes the rest of the code.
Ok. I took out "return lookupvalue;" and left everything else the same. The barcode scans successfully and the address field is populated with "Unknown".
When you ran it before, it returned "1NF314421199" with no additional spaces?
There appears to be 5 extra spaces added at the end.